diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2010-08-05 13:58:20 +0200 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2010-08-05 13:58:20 +0200 |
commit | dfb5eaffb71a423592df228c09bb4a44bda05d6d (patch) | |
tree | c659d82b7b01fdadc7d58ec2dbd640a56448624b | |
parent | 814e1d55b15f02b07b0c27d8d13f17ae6a2a6d71 (diff) | |
download | gconf-dfb5eaffb71a423592df228c09bb4a44bda05d6d.tar.gz |
[gsettings] Handle empty lists on migration
g_variant_new() doesn't like empty array-typed GVariantBuilder instances.
See bug 625663 for details.
-rw-r--r-- | gsettings/gsettings-data-convert.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gsettings/gsettings-data-convert.c b/gsettings/gsettings-data-convert.c index 4effcb5b..07ccbe8a 100644 --- a/gsettings/gsettings-data-convert.c +++ b/gsettings/gsettings-data-convert.c @@ -183,13 +183,18 @@ handle_file (const gchar *filename) case GCONF_VALUE_STRING: builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); list = gconf_value_get_list (value); - for (l = list; l; l = l->next) + if (list != NULL) { - GConfValue *lv = l->data; - s = gconf_value_get_string (lv); - g_variant_builder_add (builder, "s", s); + for (l = list; l; l = l->next) + { + GConfValue *lv = l->data; + s = gconf_value_get_string (lv); + g_variant_builder_add (builder, "s", s); + } + v = g_variant_new ("as", builder); } - v = g_variant_new ("as", builder); + else + v = g_variant_new_array (G_VARIANT_TYPE_STRING, NULL, 0); g_variant_ref_sink (v); if (dry_run) @@ -209,13 +214,18 @@ handle_file (const gchar *filename) case GCONF_VALUE_INT: builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); list = gconf_value_get_list (value); - for (l = list; l; l = l->next) + if (list != NULL) { - GConfValue *lv = l->data; - ii = gconf_value_get_int (lv); - g_variant_builder_add (builder, "i", ii); + for (l = list; l; l = l->next) + { + GConfValue *lv = l->data; + ii = gconf_value_get_int (lv); + g_variant_builder_add (builder, "i", ii); + } + v = g_variant_new ("ai", builder); } - v = g_variant_new ("ai", builder); + else + v = g_variant_new_array (G_VARIANT_TYPE_INT32, NULL, 0); g_variant_ref_sink (v); if (dry_run) |