diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-08-18 02:06:07 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-08-18 02:06:07 +0800 |
commit | bcac21fc4fb9d3fedda5e57a111d3f188cd69396 (patch) | |
tree | 38964b964611c0cfad6e1ee604786cf595dc0046 | |
parent | 63973908d495105b4c1aae36ee4f42628292c1f8 (diff) | |
download | gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar.gz gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar.bz2 gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar.lz gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar.xz gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.tar.zst gsoc2013-epiphany-bcac21fc4fb9d3fedda5e57a111d3f188cd69396.zip |
Fix crash when reading the options file. Bug #351788. Actually return the
2006-08-17 Christian Persch <chpe@cvs.gnome.org>
* lib/ephy-print-utils.c:
Fix crash when reading the options file. Bug #351788.
Actually return the settings object.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/ephy-print-utils.c | 68 |
2 files changed, 43 insertions, 32 deletions
@@ -1,5 +1,12 @@ 2006-08-17 Christian Persch <chpe@cvs.gnome.org> + * lib/ephy-print-utils.c: + + Fix crash when reading the options file. Bug #351788. + Actually return the settings object. + +2006-08-17 Christian Persch <chpe@cvs.gnome.org> + * data/epiphany-pango.schemas: Enable pango for Thai locale. Bug #339532. diff --git a/lib/ephy-print-utils.c b/lib/ephy-print-utils.c index 8e6ba5feb..135852adc 100644 --- a/lib/ephy-print-utils.c +++ b/lib/ephy-print-utils.c @@ -89,15 +89,19 @@ ephy_print_utils_settings_new_from_key_file (GKeyFile *key_file, GtkPrintSettings *settings; gchar **keys; gsize n_keys, i; + GError *err = NULL; g_return_val_if_fail (key_file != NULL, NULL); keys = g_key_file_get_keys (key_file, PRINT_SETTINGS_GROUP, &n_keys, - error); - if (*error != NULL) - return NULL; + &err); + if (err != NULL) + { + g_propagate_error (error, err); + return NULL; + } settings = gtk_print_settings_new (); @@ -118,7 +122,7 @@ ephy_print_utils_settings_new_from_key_file (GKeyFile *key_file, g_strfreev (keys); - return NULL; + return settings; } /** @@ -142,20 +146,24 @@ ephy_print_utils_settings_to_file (GtkPrintSettings *settings, gboolean retval; char *data = NULL; gsize len; + GError *err = NULL; g_return_val_if_fail (GTK_IS_PRINT_SETTINGS (settings), FALSE); g_return_val_if_fail (file_name != NULL, FALSE); keyfile = g_key_file_new (); - retval = ephy_print_utils_settings_to_key_file (settings, keyfile, error); + retval = ephy_print_utils_settings_to_key_file (settings, keyfile, &err); if (!retval) goto out; - data = g_key_file_to_data (keyfile, &len, error); + data = g_key_file_to_data (keyfile, &len, &err); if (!data) goto out; - retval = g_file_set_contents (file_name, data, len, error); + retval = g_file_set_contents (file_name, data, len, &err); out: + if (err != NULL) + g_propagate_error (error, err); + g_key_file_free (keyfile); g_free (data); @@ -197,13 +205,6 @@ ephy_print_utils_settings_to_key_file (GtkPrintSettings *settings, return TRUE; } - - - - - - - /** * ephy_print_utils_page_setup_new_from_file: * @file_name: the filename to read the page_setup from @@ -259,6 +260,7 @@ ephy_print_utils_page_setup_new_from_key_file (GKeyFile *key_file, gdouble width, height, top, bottom, left, right; char *name = NULL, *ppd_name = NULL, *display_name = NULL, *orientation = NULL; gboolean retval = TRUE; + GError *err = NULL; g_return_val_if_fail (key_file != NULL, NULL); @@ -270,8 +272,9 @@ ephy_print_utils_page_setup_new_from_key_file (GKeyFile *key_file, } #define GET_DOUBLE(kf, group, name, v) \ -v = g_key_file_get_double (kf, group, name, error); \ -if (*error != NULL) {\ +v = g_key_file_get_double (kf, group, name, &err); \ +if (err != NULL) {\ + g_propagate_error (error, err);\ retval = FALSE;\ goto out;\ } @@ -291,19 +294,23 @@ if (*error != NULL) {\ "PPDName", NULL); display_name = g_key_file_get_string (key_file, PAPER_SIZE_GROUP, "DisplayName", NULL); + orientation = g_key_file_get_string (key_file, PAGE_SETUP_GROUP, + "Orientation", NULL); + + if ((ppd_name == NULL && name == NULL) || orientation == NULL) + { + g_set_error (error, ERROR_QUARK, 0, "Not a valid epiphany page setup file"); + retval = FALSE; + goto out; + } if (ppd_name != NULL) { paper_size = gtk_paper_size_new_from_ppd (ppd_name, display_name, width, height); - } else if (name != NULL) { + } else { paper_size = gtk_paper_size_new_custom (name, display_name, width, height, GTK_UNIT_MM); - } else { - g_set_error (error, ERROR_QUARK, 0, "Not a valid epiphany page setup file"); - retval = FALSE; - goto out; } - g_assert (paper_size != NULL); page_setup = gtk_page_setup_new (); @@ -315,19 +322,16 @@ if (*error != NULL) {\ gtk_page_setup_set_left_margin (page_setup, left, GTK_UNIT_MM); gtk_page_setup_set_right_margin (page_setup, right, GTK_UNIT_MM); - orientation = g_key_file_get_string (key_file, PAGE_SETUP_GROUP, - "Orientation", NULL); - if (orientation != NULL) { - gtk_page_setup_set_orientation (page_setup, - ephy_string_enum_from_string (GTK_TYPE_PAGE_ORIENTATION, - orientation)); - g_free (orientation); - } - + gtk_page_setup_set_orientation (page_setup, + ephy_string_enum_from_string (GTK_TYPE_PAGE_ORIENTATION, + orientation)); out: + if (!retval) g_warning ("page_setup_new_from_keyfile failed"); //XXX + + g_free (ppd_name); g_free (name); g_free (display_name); - g_free (ppd_name); + g_free (orientation); return page_setup; } |