aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-prefs-locations.c
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 /src/datetime-prefs-locations.c
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
Diffstat (limited to 'src/datetime-prefs-locations.c')
-rw-r--r--src/datetime-prefs-locations.c15
1 files changed, 12 insertions, 3 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