aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-29 11:58:28 -0500
committerTed Gould <ted@gould.cx>2011-03-29 11:58:28 -0500
commit5d401d9c978453c29c6d74694fe68e4155534283 (patch)
treea83abdf4b84f9a72af1645ca56cbd40d00414551
parent6185b56b563e39d10801e555bf3b51a18f586bdd (diff)
parentb86cc25455f38c4162ecd1fe6add20373c789980 (diff)
downloadayatana-indicator-datetime-5d401d9c978453c29c6d74694fe68e4155534283.tar.gz
ayatana-indicator-datetime-5d401d9c978453c29c6d74694fe68e4155534283.tar.bz2
ayatana-indicator-datetime-5d401d9c978453c29c6d74694fe68e4155534283.zip
Fix crash with GVariantBuilder, unref a timedate and ensure that we always have a separator
-rw-r--r--src/datetime-prefs-locations.c15
-rw-r--r--src/datetime-service.c10
-rw-r--r--src/utils.c2
3 files changed, 19 insertions, 8 deletions
diff --git a/src/datetime-prefs-locations.c b/src/datetime-prefs-locations.c
index 5550450..d13f95a 100644
--- a/src/datetime-prefs-locations.c
+++ b/src/datetime-prefs-locations.c
@@ -229,6 +229,7 @@ fill_from_settings (GObject * store, GSettings * conf)
static void
save_to_settings (GObject * store, GSettings * conf)
{
+ gboolean empty = TRUE;
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
@@ -246,13 +247,21 @@ save_to_settings (GObject * store, GSettings * conf)
gchar * settings_string = g_strdup_printf("%s %s", strzone, strname);
g_variant_builder_add (&builder, "s", settings_string);
g_free (settings_string);
+ empty = FALSE;
}
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
}
- GVariant * locations = g_variant_builder_end (&builder);
- g_settings_set_strv (conf, SETTINGS_LOCATIONS_S, g_variant_get_strv (locations, NULL));
- g_variant_unref (locations);
+ if (empty) {
+ /* Empty list */
+ g_variant_builder_clear (&builder);
+ g_settings_set_strv (conf, SETTINGS_LOCATIONS_S, NULL);
+ }
+ else {
+ GVariant * locations = g_variant_builder_end (&builder);
+ g_settings_set_strv (conf, SETTINGS_LOCATIONS_S, g_variant_get_strv (locations, NULL));
+ g_variant_unref (locations);
+ }
}
static gboolean
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 7e01f88..905128b 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -438,11 +438,11 @@ update_timezone_menu_items(gpointer user_data) {
gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S);
- if (len > 0) {
- dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
- dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
- dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
- } else {
+ dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show);
+ dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+
+ if (len == 0) {
g_debug("No locations configured (Empty List)");
return FALSE;
}
diff --git a/src/utils.c b/src/utils.c
index 537495b..d8851aa 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -233,6 +233,8 @@ generate_format_string_at_time (GDateTime * time)
g_date_time_unref(future_bound);
}
+ g_date_time_unref (now);
+
return generate_format_string_full(show_day, show_date);
}