GNOME Bugzilla – Bug 761381
gtk_settings_reset_property does not always reset to correct value
Last modified: 2016-02-04 09:47:55 UTC
Created attachment 320164 [details] [review] gtksettings: correctly reset property Currently gtk_settings_reset_property resets property to default value of pspec, but it is not always correct default value... Default values can be changed with settings.ini files. Example with gnome-terminal: 1) User enables Global Dark Theme from Tweak Tool. 2) Theme variant is selected - default. In this case gnome-terminal will call gtk_settings_reset_property that will reset dark theme to FALSE. And now gnome-terminal use light theme variant instead of dark.
Review of attachment 320164 [details] [review]: It is a bit unfortunate to reload multiple key files for a single key. It also introduces a subtle change of semantics: We're not monitoring these files, but if you reset a key, you'll get the newer value - but only for that one key.
(In reply to Matthias Clasen from comment #1) > Review of attachment 320164 [details] [review] [review]: > > It is a bit unfortunate to reload multiple key files for a single key. It > also introduces a subtle change of semantics: We're not monitoring these > files, but if you reset a key, you'll get the newer value - but only for > that one key. And how about this: Store property values (from .ini files) in hash table and then when resetting property get value form hash table. If there is no property in hash table then reset to pspec default value? Has there been any discussion about possibility to monitor settings.ini files?
Created attachment 320210 [details] [review] gtksettings: correctly reset property (v2)
The idea is good. One change I would propose it to attach the overridden default value to the param specs with g_param_spec_set_qdata instead of maintaining a separate hash table.
Created attachment 320228 [details] [review] gtksettings: reset property to correct default value
Review of attachment 320228 [details] [review]: Looks good now, thanks
Created attachment 320340 [details] [review] gtksettings: fix critical warning Commit 5186aeb90f52c941a2642b04ebfb54e9d8f8ea11 introduced critical warning - g_value_copy: assertion 'g_value_type_compatible (...)' failed. P.S. Why boolean is created as G_TYPE_LONG in gtk_settings_load_from_key_file?
I think it is worth trying to just use set_boolean. Looking through the history, this is very old code from 2001, and it may predate boolean support in GValue.
I think that it is better to stick with patch that I created... Changing boolean from G_TYPE_LONG to G_TYPE_BOOLEAN will not be enough. Same problem will be with G_TYPE_INT/UINT that is also created as G_TYPE_LONG, same problem with string that is created as G_TYPE_GSTRING. All that will case same critical warning when resetting property. Only G_TYPE_DOUBLE is created with correct type.
Review of attachment 320340 [details] [review]: Lets stick with this for now, then