diff options
author | Ted Gould <ted@gould.cx> | 2011-03-30 10:58:17 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-30 10:58:17 -0500 |
commit | fbd5c581cc7f8ca4bc7386f6957b5c41e3d266cf (patch) | |
tree | b3e4f5a41c1926e8a430e384432c4ac455023ac5 | |
parent | 073715557f637c7cd87c906718d99a3c682f7e5f (diff) | |
download | ayatana-indicator-datetime-fbd5c581cc7f8ca4bc7386f6957b5c41e3d266cf.tar.gz ayatana-indicator-datetime-fbd5c581cc7f8ca4bc7386f6957b5c41e3d266cf.tar.bz2 ayatana-indicator-datetime-fbd5c581cc7f8ca4bc7386f6957b5c41e3d266cf.zip |
Protecting against NULL values
-rw-r--r-- | src/indicator-datetime.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 5d35c59..c96ec48 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1200,21 +1200,28 @@ calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, I g_debug("Changing calendar property: %s", prop); if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_MARKS)) { ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data)); - GVariantIter *iter; - gint day; - g_debug("\tMarks: %s", g_variant_print(value, FALSE)); + if (value != NULL) { + GVariantIter *iter; + gint day; - g_variant_get (value, "ai", &iter); - while (g_variant_iter_loop (iter, "i", &day)) { - ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), day); + g_debug("\tMarks: %s", g_variant_print(value, FALSE)); + + g_variant_get (value, "ai", &iter); + while (g_variant_iter_loop (iter, "i", &day)) { + ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), day); + } + g_variant_iter_free (iter); + } else { + g_debug("\tMarks: <cleared>"); } - g_variant_iter_free (iter); } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { - gsize size = 3; - const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint)); - g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]); - ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]); + if (value != NULL) { + gsize size = 3; + const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint)); + g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]); + ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]); + } } else { g_warning("Indicator Item property '%s' unknown", prop); } |