diff options
author | Ted Gould <ted@gould.cx> | 2009-12-16 21:43:40 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2009-12-16 21:43:40 -0600 |
commit | 8ae44198e16818478035a666e2f998d8e584ab7c (patch) | |
tree | 4bcfa17411cf10321e17a7b8bba28ddd44d3bd5c /libdbusmenu-gtk | |
parent | 1630c946d0a760ebf4796db40d4e70ce454e2e74 (diff) | |
download | libdbusmenu-8ae44198e16818478035a666e2f998d8e584ab7c.tar.gz libdbusmenu-8ae44198e16818478035a666e2f998d8e584ab7c.tar.bz2 libdbusmenu-8ae44198e16818478035a666e2f998d8e584ab7c.zip |
Protect against NULL values and treat them as default values.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/client.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 80d067f..80d2b4f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -147,15 +147,17 @@ static void process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { if (!IS_GENERICMENUITEM(gmi)) return; - if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; - const gchar * strval = g_value_get_string(value); GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; - if (!g_strcmp0(strval, "checkbox")) { - type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; - } else if (!g_strcmp0(strval, "radio")) { - type = GENERICMENUITEM_CHECK_TYPE_RADIO; + if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { + const gchar * strval = g_value_get_string(value); + + if (!g_strcmp0(strval, "checkbox")) { + type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; + } else if (!g_strcmp0(strval, "radio")) { + type = GENERICMENUITEM_CHECK_TYPE_RADIO; + } } genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); @@ -168,15 +170,17 @@ static void process_toggle_checked (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { if (!IS_GENERICMENUITEM(gmi)) return; - if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; - const gchar * strval = g_value_get_string(value); GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; - if (!g_strcmp0(strval, "checked")) { - state = GENERICMENUITEM_STATE_CHECKED; - } else if (!g_strcmp0(strval, "indeterminate")) { - state = GENERICMENUITEM_STATE_INDETERMINATE; + if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { + const gchar * strval = g_value_get_string(value); + + if (!g_strcmp0(strval, "checked")) { + state = GENERICMENUITEM_STATE_CHECKED; + } else if (!g_strcmp0(strval, "indeterminate")) { + state = GENERICMENUITEM_STATE_INDETERMINATE; + } } genericmenuitem_set_state(GENERICMENUITEM(gmi), state); |