[gconf] [gsettings] Handle empty lists on migration
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gconf] [gsettings] Handle empty lists on migration
- Date: Thu, 5 Aug 2010 11:59:17 +0000 (UTC)
commit dfb5eaffb71a423592df228c09bb4a44bda05d6d
Author: Tomas Bzatek <tbzatek redhat com>
Date: Thu Aug 5 13:58:20 2010 +0200
[gsettings] Handle empty lists on migration
g_variant_new() doesn't like empty array-typed GVariantBuilder instances.
See bug 625663 for details.
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 4effcb5..07ccbe8 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]