GNOME Bugzilla – Bug 683789
Support for converting 's' to 'as' in gsettings-data-convert
Last modified: 2018-08-17 13:55:03 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.
+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...
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.
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!