From 235f4958a97bb82c50a178ed0d6f0ac1e3cdbbe4 Mon Sep 17 00:00:00 2001 From: Allison Lortie Date: Fri, 2 Feb 2018 14:20:09 +0100 Subject: [PATCH] gsettings: remove redundancy in 'list-recursive' Some projects use child schemas in an odd way: they link children which already have their path pre-defined. This causes the child schema (and its keys) to be printed out twice: - once because it is, itself, a non-relocatable schema - once, as a recursion from its parent We can avoid this by not recursing into child schemas that are non-relocatable (on the assumption that they will be enumerated elsewhere). https://bugzilla.gnome.org/show_bug.cgi?id=723003 --- gio/gsettings-tool.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c index 57eb838a1..b7dd9d8fb 100644 --- a/gio/gsettings-tool.c +++ b/gio/gsettings-tool.c @@ -262,10 +262,28 @@ list_recursively (GSettings *settings) children = g_settings_list_children (settings); for (i = 0; children[i]; i++) { + gboolean will_see_elsewhere = FALSE; GSettings *child; child = g_settings_get_child (settings, children[i]); - list_recursively (child); + + if (global_settings == NULL) + { + /* we're listing all non-relocatable settings objects from the + * top-level, so if this one is non-relocatable, don't recurse, + * because we will pick it up later on. + */ + + GSettingsSchema *child_schema; + + g_object_get (child, "settings-schema", &child_schema, NULL); + will_see_elsewhere = !is_relocatable_schema (child_schema); + g_settings_schema_unref (child_schema); + } + + if (!will_see_elsewhere) + list_recursively (child); + g_object_unref (child); }