Fix crash on NULL values from GConf

This commit is contained in:
Lauris Kaplinski 2002-02-05 11:13:58 +00:00
parent 084879bb45
commit 533c0f416b
8 changed files with 55 additions and 47 deletions

View file

@ -8,6 +8,8 @@
(realize_2_cb): Comment out to kill warning
(realize_cb): Ditto
(real_realize_cb): Ditto
(string_to_background_type): Treat NULL string as default
(string_to_orientation): Ditto
2002-01-13 Seth Nickell <snickell@stanford.edu>

View file

@ -82,22 +82,21 @@ set_picture_is_present (gboolean present)
static BackgroundType
string_to_background_type (char *string)
{
BackgroundType type;
BackgroundType type = BACKGROUND_TYPE_NO_PICTURE;
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
type = BACKGROUND_TYPE_WALLPAPER;
} else if (!strncmp (string, "centered", sizeof ("centered"))) {
type = BACKGROUND_TYPE_CENTERED;
} else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
type = BACKGROUND_TYPE_SCALED;
} else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
type = BACKGROUND_TYPE_STRETCHED;
} else {
type = BACKGROUND_TYPE_NO_PICTURE;
if (string) {
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
type = BACKGROUND_TYPE_WALLPAPER;
} else if (!strncmp (string, "centered", sizeof ("centered"))) {
type = BACKGROUND_TYPE_CENTERED;
} else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
type = BACKGROUND_TYPE_SCALED;
} else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
type = BACKGROUND_TYPE_STRETCHED;
}
g_free (string);
}
g_free (string);
return type;
}
@ -137,17 +136,17 @@ orientation_to_string (orientation_t orientation)
static orientation_t
string_to_orientation (gchar *string)
{
orientation_t type;
orientation_t type = ORIENTATION_SOLID;
if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
type = ORIENTATION_VERT;
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
type = ORIENTATION_HORIZ;
} else {
type = ORIENTATION_SOLID;
if (string) {
if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
type = ORIENTATION_VERT;
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
type = ORIENTATION_HORIZ;
}
g_free (string);
}
g_free (string);
return type;
}

View file

@ -2,6 +2,9 @@
* gnome-default-applications-properties.c (initialize_default_applications):
Use glib methods instead of deprecated libgnome ones
(read_editor): Do not crash on NULL value
(read_help_viewer): Ditto
(read_browser): Ditto
2002-01-19 Seth Nickell <snickell@stanford.edu>

View file

@ -125,7 +125,7 @@ read_editor (GConfClient *client,
if (possible_editors[i].in_path == FALSE)
continue;
if (strcmp (editor, possible_editors[i].executable_name) == 0 &&
if (editor && strcmp (editor, possible_editors[i].executable_name) == 0 &&
needs_term == possible_editors[i].needs_term &&
accepts_lineno == possible_editors[i].accepts_lineno) {
gtk_entry_set_text (GTK_ENTRY (WID ("text_select_combo_entry")),
@ -209,7 +209,7 @@ read_browser (GConfClient *client,
if (possible_browsers[i].in_path == FALSE)
continue;
if (strcmp (browser, possible_browsers[i].executable_name) == 0 &&
if (browser && strcmp (browser, possible_browsers[i].executable_name) == 0 &&
needs_term == possible_browsers[i].needs_term &&
nremote == possible_browsers[i].nremote) {
gtk_entry_set_text (GTK_ENTRY (WID ("web_select_combo_entry")),
@ -291,7 +291,7 @@ read_help_viewer (GConfClient *client,
if (possible_help_viewers[i].in_path == FALSE)
continue;
if (strcmp (help_viewer, possible_help_viewers[i].executable_name) == 0 &&
if (help_viewer && strcmp (help_viewer, possible_help_viewers[i].executable_name) == 0 &&
needs_term == possible_help_viewers[i].needs_term &&
accepts_lineno == possible_help_viewers[i].accepts_urls) {
gtk_entry_set_text (GTK_ENTRY (WID ("help_select_combo_entry")),

View file

@ -3,6 +3,7 @@
* gnome-mouse-properties.c (drawing_area_expose_event): Kill warning
(dialog_button_clicked_cb): Use G_TYPE_STRING
(dialog_button_clicked_cb): Use GtkDialog
(left_handed_toggle_cb): Do not crash on NULL value
Tue Jan 8 15:47:24 2002 Jonathan Blandford <jrb@redhat.com>

View file

@ -267,7 +267,7 @@ drawing_area_expose_event (GtkWidget *widget,
static void
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
{
if (gconf_value_get_bool (value))
if (value && gconf_value_get_bool (value))
g_object_set (G_OBJECT (image),
"pixbuf", left_handed_pixbuf,
NULL);

View file

@ -1,5 +1,8 @@
2002-02-04 Lauris Kaplinski <lauris@ximian.com>
* preferences.c (read_wptype_from_string): Do not crash on NULL
(read_orientation_from_string): Ditto
* applier.c (bg_applier_dispose): Replace deprecated methods
(draw_disabled_message): Use gtk_image instead of gtk_pixmap,
replace deprecated methods

View file

@ -271,22 +271,22 @@ bg_preferences_merge_entry (BGPreferences *prefs,
static wallpaper_type_t
read_wptype_from_string (gchar *string)
{
wallpaper_type_t type;
wallpaper_type_t type = -1;
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
type = WPTYPE_TILED;
} else if (!strncmp (string, "centered", sizeof ("centered"))) {
type = WPTYPE_CENTERED;
} else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
type = WPTYPE_SCALED;
} else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
type = WPTYPE_STRETCHED;
} else if (!strncmp (string, "embossed", sizeof ("embossed"))) {
type = WPTYPE_EMBOSSED;
} else {
type = -1;
if (string) {
if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) {
type = WPTYPE_TILED;
} else if (!strncmp (string, "centered", sizeof ("centered"))) {
type = WPTYPE_CENTERED;
} else if (!strncmp (string, "scaled", sizeof ("scaled"))) {
type = WPTYPE_SCALED;
} else if (!strncmp (string, "stretched", sizeof ("stretched"))) {
type = WPTYPE_STRETCHED;
} else if (!strncmp (string, "embossed", sizeof ("embossed"))) {
type = WPTYPE_EMBOSSED;
}
g_free (string);
}
g_free (string);
return type;
}
@ -294,17 +294,17 @@ read_wptype_from_string (gchar *string)
static orientation_t
read_orientation_from_string (gchar *string)
{
orientation_t type;
orientation_t type = ORIENTATION_SOLID;
if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
type = ORIENTATION_VERT;
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
type = ORIENTATION_HORIZ;
} else {
type = ORIENTATION_SOLID;
if (string) {
if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) {
type = ORIENTATION_VERT;
} else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) {
type = ORIENTATION_HORIZ;
}
g_free (string);
}
g_free (string);
return type;
}