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
This commit is contained in:
Allison Lortie 2018-02-02 14:20:09 +01:00 committed by Philip Withnall
parent 32cc60dbff
commit 235f4958a9

View File

@ -262,10 +262,28 @@ list_recursively (GSettings *settings)
children = g_settings_list_children (settings); children = g_settings_list_children (settings);
for (i = 0; children[i]; i++) for (i = 0; children[i]; i++)
{ {
gboolean will_see_elsewhere = FALSE;
GSettings *child; GSettings *child;
child = g_settings_get_child (settings, children[i]); child = g_settings_get_child (settings, children[i]);
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); list_recursively (child);
g_object_unref (child); g_object_unref (child);
} }