[glib] gsettings: remove redundancy in 'list-recursive'
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gsettings: remove redundancy in 'list-recursive'
- Date: Fri, 2 Feb 2018 13:41:17 +0000 (UTC)
commit 235f4958a97bb82c50a178ed0d6f0ac1e3cdbbe4
Author: Allison Lortie <desrt desrt ca>
Date: Fri Feb 2 14:20:09 2018 +0100
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 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsettings-tool.c b/gio/gsettings-tool.c
index 57eb838..b7dd9d8 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]