After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 683789 - Support for converting 's' to 'as' in gsettings-data-convert
Support for converting 's' to 'as' in gsettings-data-convert
Status: RESOLVED WONTFIX
Product: GConf
Classification: Deprecated
Component: gsettings
CVS HEAD
Other Linux
: Normal enhancement
: ---
Assigned To: GConf Maintainers
GConf Maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2012-09-11 10:26 UTC by Timo Jyrinki
Modified: 2018-08-17 13:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support 's' to 'as' migrations (1.94 KB, patch)
2012-09-11 10:26 UTC, Timo Jyrinki
none Details | Review
v2 of the patch (2.07 KB, patch)
2012-09-14 14:07 UTC, Timo Jyrinki
none Details | Review

Description Timo Jyrinki 2012-09-11 10:26:49 UTC
Created attachment 224007 [details] [review]
Support 's' to 'as' migrations

Sometimes a simple gconf -> gsettings conversion is not enough. An example would be trying to convert /apps/metacity/window_keybindings/move_to_workspace_left to org.gnome.desktop.wm.keybindings's move-to-workspace-left.

It'd be useful to try migrating as a string array instead in these cases.
Comment 1 Christian Persch 2012-09-11 13:22:50 UTC
+if (!g_settings_set (settings, keys[j], "s",
+                     gconf_value_get_string (value)))

Not correct. FALSE return here means the key wasn't writable; not that it's not of type "s". Setting the wrong type gets you a g_critical / crash.

So you need to check the key type first; for that you'll need new gsettings API that's not in glib yet.

+ g_print ("Setting the target key '%s' as a string failed, converting the string to a string array.\n", keys[j]);

g_printerr().

+                    builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+                    g_variant_builder_add (builder, "s", gconf_value_get_string (value));
+                    v = g_variant_new ("as", builder);
+                    g_variant_ref_sink (v);
+                    g_settings_set_value (settings, keys[j], v);
+                    g_variant_unref (v);
+                    g_variant_builder_unref (builder);

That's very awkward gvariant[builder] use...
Comment 2 Timo Jyrinki 2012-09-14 14:07:37 UTC
Created attachment 224320 [details] [review]
v2 of the patch

Thank you for the comments. I got a tip about g_settings_get_range and indeed it can be used to check the target type. The attached patch results in same in practical functionality regarding the problematic keys as the first version of the patch, but does not have GLib-GIO-CRITICAL:s anymore.

Changed the g_print finally to g_debug as it's not an error anymore as the problematic target key type is detected.

This of course ignores the possibility that the target key is of different type than either string or string array, and in that case GLib-GIO-CRITICAL:s continue to be outputted similar to the behavior without the patch at all. I did not encounter such keys, though.
Comment 3 André Klapper 2018-08-17 13:55:03 UTC
GConf has been deprecated since 2011.

GConf is not under active development anymore. Its codebase has been archived:
https://gitlab.gnome.org/Archive/gconf/commits/master

dconf and gsettings are its successors. See https://developer.gnome.org/gio/stable/ch34.html and https://developer.gnome.org/GSettings/ for porting info.

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect
reality. Feel free to open a task in GNOME Gitlab if the issue described in this task still applies to a recent + supported version of dconf/gsettings. Thanks!