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 723003 - gsettings list-recursively reports some keys multiple times
gsettings list-recursively reports some keys multiple times
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
2.38.x
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-01-26 08:22 UTC by Emilio Pozuelo Monfort
Modified: 2018-04-12 00:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gsettings: remove redundancy in 'list-recursive' (1.64 KB, patch)
2018-02-02 13:23 UTC, Allison Karlitskaya (desrt)
none Details | Review
gsettings: remove redundancy in 'list-recursive' (1.79 KB, patch)
2018-02-02 13:35 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Emilio Pozuelo Monfort 2014-01-26 08:22:14 UTC
list-recursively reports most (though not all) keys multiple times, e.g.:

org.gnome.gedit.state.window bottom-panel-active-page 0
org.gnome.gedit.state.window bottom-panel-active-page 0
org.gnome.gedit.state.window bottom-panel-active-page 0

Might be because it recurses on org.gnome.gedit, then on org.gnome.gedit.state and then on org.gnome.gedit.state.window, reporting this key thrice.

Original report: http://bugs.debian.org/730799
Comment 1 Allison Karlitskaya (desrt) 2018-02-02 10:52:02 UTC
This is because the schema is listed as both a child (from the parent), but is given a precise path (from the child).  It therefore gets a visit as part of the enumeration of the parent, as well as its own visit.  This wasn't meant to be how this feature is used, but clearly some people are using it that way.
Comment 2 Allison Karlitskaya (desrt) 2018-02-02 10:55:02 UTC
Two possible fixes here:

1) add a warning to the schema compiler about this behaviour [as should have existed in the first place] and hope that people slowly fix the issue; or

2) make 'gsettings list-recursively' smarter about not revisiting paths multiple times.  this would be pretty easy: just build a hash table of paths that we've already visited.
Comment 3 Philip Withnall 2018-02-02 10:56:10 UTC
I would suggest doing both.
Comment 4 Allison Karlitskaya (desrt) 2018-02-02 10:56:30 UTC
3) if 'gsettings list-recursively' is run with no specific schemaid and it encounters a child which has its own path specified, then don't iterate it, knowing that it will be handled on its own from the toplevel elsewhere
Comment 5 Allison Karlitskaya (desrt) 2018-02-02 13:23:57 UTC
Created attachment 367810 [details] [review]
gsettings: remove redundancy in 'list-recursive'
Comment 6 Allison Karlitskaya (desrt) 2018-02-02 13:29:13 UTC
I think there's actually no reason to forbid people from having child relationships to schemas that have their own path (when said settings will always be at only this one path).  This might not have been the intended use case, but there's also nothing wrong with it.  On one hand, having the fixed path for a given schema can be useful (to directly instantiate it), and having the child relationship can also be useful (to use get_child()).  Even if these are two separate ways of doing the same thing, there is no real problem with a given schema supporting them both.

I'm also not super keen on adding a new warning to the schema compiler that will annoy a bunch of people for little gain.

Let's just go with this.
Comment 7 Philip Withnall 2018-02-02 13:29:22 UTC
Review of attachment 367810 [details] [review]:

Might be good to clarify in the commit message that while this use of child schemas is ‘odd’, you’ve decided it’s correct and supported.

::: gio/gsettings-tool.c
@@ +282,3 @@
+
+	  if (will_see_elsewhere)
+	    continue;

Isn’t `child` leaked on this continue path?
Comment 8 Allison Karlitskaya (desrt) 2018-02-02 13:30:27 UTC
Review of attachment 367810 [details] [review]:

::: gio/gsettings-tool.c
@@ +282,3 @@
+
+	  if (will_see_elsewhere)
+	    continue;

This is correct.  My clever use of a variable to avoid leaking the schema has failed to save me here.  grr.
Comment 9 Allison Karlitskaya (desrt) 2018-02-02 13:35:24 UTC
Created attachment 367811 [details] [review]
gsettings: remove redundancy in 'list-recursive'
Comment 10 Philip Withnall 2018-02-02 13:40:21 UTC
Review of attachment 367811 [details] [review]:

++
Comment 11 Philip Withnall 2018-02-02 13:41:23 UTC
Attachment 367811 [details] pushed as 235f495 - gsettings: remove redundancy in 'list-recursive'
Comment 12 Vincent Lefevre 2018-04-04 12:06:53 UTC
2.56.0 (which has 235f495 according to its changelog) is still not fixed:

cventin:~> gsettings list-recursively | grep org.gnome.evolution.window
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
org.gnome.evolution.window width 0
org.gnome.evolution.window maximized false
org.gnome.evolution.window height 0
org.gnome.evolution.window x 0
org.gnome.evolution.window y 0
Comment 13 Philip Withnall 2018-04-10 10:29:01 UTC
Are you sure those keys/values are for the same path? If I run that, I get different values for each instance of each key, which indicates to me that the keys are being listed for schema instances at different paths, which is not what this bug is about. This bug is about the keys for a single schema instance (at a single path) being listed multiple times.
Comment 14 Vincent Lefevre 2018-04-10 13:00:06 UTC
I do not provide a path, i.e. I just use:

  gsettings list-recursively

and I can see no paths printed. If the values are path-dependent, then it makes no sense to output them without the corresponding path, and there is even a loss of information (the goal is to keep some form of human-readable backup of my current config). This would be a different bug, I assume.
Comment 15 Philip Withnall 2018-04-11 13:35:39 UTC
Yes, please file that as a separate bug report. Thanks.
Comment 16 Vincent Lefevre 2018-04-12 00:05:28 UTC
Reported as bug 795179.