diff options
author | Michael Terry <mike@mterry.name> | 2011-03-24 13:43:07 -0500 |
---|---|---|
committer | Michael Terry <mike@mterry.name> | 2011-03-24 13:43:07 -0500 |
commit | 0b0b94a49cd63bb1e1933cbe674c944c28ac24fb (patch) | |
tree | e483d69a61e77d45ff23fa908c323f40957c5602 /src | |
parent | 594bff89b1c26340a1b0393cd17a45a48911fc9f (diff) | |
download | ayatana-indicator-datetime-0b0b94a49cd63bb1e1933cbe674c944c28ac24fb.tar.gz ayatana-indicator-datetime-0b0b94a49cd63bb1e1933cbe674c944c28ac24fb.tar.bz2 ayatana-indicator-datetime-0b0b94a49cd63bb1e1933cbe674c944c28ac24fb.zip |
fix crash when emptying location list
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime-prefs-locations.c | 15 |
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 |