Kouhei Sutou
kous****@users*****
2006年 11月 25日 (土) 12:32:19 JST
Index: tomoe/lib/glib-utils.h diff -u tomoe/lib/glib-utils.h:1.3 tomoe/lib/glib-utils.h:1.4 --- tomoe/lib/glib-utils.h:1.3 Mon Nov 20 11:04:28 2006 +++ tomoe/lib/glib-utils.h Sat Nov 25 12:32:19 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.h,v 1.3 2006/11/20 02:04:28 kous Exp $ + * $Id: glib-utils.h,v 1.4 2006/11/25 03:32:19 kous Exp $ */ @@ -34,6 +34,15 @@ g_ptr_array_free (p_array, TRUE); \ } +#define TOMOE_HANDLE_ERROR(error) do { \ + g_warning ("%s: %d: %s", \ + g_quark_to_string (error->domain), \ + error->code, \ + error->message); \ + g_error_free (error); \ + error = NULL; \ +} while (FALSE) + G_END_DECLS #endif /* __GLIB_UTILS_H__ */ Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.33 tomoe/lib/tomoe-config.c:1.34 --- tomoe/lib/tomoe-config.c:1.33 Sat Nov 25 00:57:20 2006 +++ tomoe/lib/tomoe-config.c Sat Nov 25 12:32:19 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.33 2006/11/24 15:57:20 kous Exp $ + * $Id: tomoe-config.c,v 1.34 2006/11/25 03:32:19 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -242,8 +242,7 @@ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { - g_warning (error->message); - g_error_free (error); + TOMOE_HANDLE_ERROR (error); return; } } else { @@ -252,8 +251,7 @@ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { - g_warning (error->message); - g_error_free (error); + TOMOE_HANDLE_ERROR (error); return; } } @@ -276,14 +274,12 @@ data = g_key_file_to_data (priv->key_file, &length, &error); if (error) { - g_warning (error->message); - g_error_free (error); + TOMOE_HANDLE_ERROR (error); return; } if (!g_file_set_contents (priv->filename, data, length, &error)) { - g_warning (error->message); - g_error_free (error); + TOMOE_HANDLE_ERROR (error); return; } } @@ -318,8 +314,7 @@ filename = g_key_file_get_string (key_file, dict_name, "file", &error); if (error) { - g_warning (error->message); - g_error_free (error); + TOMOE_HANDLE_ERROR (error); continue; } @@ -390,13 +385,13 @@ if (error) { switch (error->code) { case G_KEY_FILE_ERROR_NOT_FOUND: + g_error_free (error); break; case G_KEY_FILE_ERROR_INVALID_VALUE: - g_warning (error->message); + TOMOE_HANDLE_ERROR (error); break; } result = default_value; - g_error_free (error); } return result; Index: tomoe/lib/tomoe-shelf.c diff -u tomoe/lib/tomoe-shelf.c:1.7 tomoe/lib/tomoe-shelf.c:1.8 --- tomoe/lib/tomoe-shelf.c:1.7 Sat Nov 25 00:57:20 2006 +++ tomoe/lib/tomoe-shelf.c Sat Nov 25 12:32:19 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-shelf.c,v 1.7 2006/11/24 15:57:20 kous Exp $ + * $Id: tomoe-shelf.c,v 1.8 2006/11/25 03:32:19 kous Exp $ */ #include "tomoe-dict.h" @@ -165,7 +165,7 @@ { TomoeShelfPrivate *priv; - g_return_if_fail (shelf); + g_return_val_if_fail (shelf, FALSE); priv = TOMOE_SHELF_GET_PRIVATE (shelf); return g_hash_table_lookup (priv->dicts, name) != NULL;