-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panel/plugin: Fix settings storing/restoring #1745
Conversation
This isn't needed. It complicates the code unnecessarily. Please read my replies at #1744 |
mSettings.storeToCache(); | ||
return QDialog::closeEvent(event); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want only to save settings. We also want to reflect the changes that the Rest button causes in the GUI. There's no guarantee that it happens. Each plugin needs its own handling and that makes this change redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also want to reflect the changes that the Rest button causes in the GUI.
The Reset button just restores the values from cache (pre-existing) into the settings object and calls locadSettings()
which must each plugin's config dialog implement. And that's exactly, what you described, it should do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from not being needed, this is also at odd with the on-the-fly applying of settings change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@palinek, please forget about what I wrote at #1741 (comment). As I said at #1741 (comment), I remembered everything later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from not being needed, this is also at odd with the on-the-fly applying of settings change.
?
Aren't you misreading the code? This does:
- when the config dialog is closed, the current (and applied) settings are stored into "old values cache"
- when the config dialog is opened next time, the reset button will be (optionally) resetting to values "from previous close" (or from the plugin creation if no config showed yet)
The close logic does nothing to the currently used configuration values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK but it isn't needed. We don't need to be worried about the cache; it'll be correct if Reset does its job.
- Add emitting settingsChanged() into PluginSettings::loadFromCache() to notify plugin/users, that settings were updated. Previously the signal was probably emitted by the underlying object detecting the settings file changed, but this is not the case any more (probably enhancement in the underlying Qt's QSettings optimization). - Add PlutingSettings::storeToCache() for the plugin configure dialog to be able to store to cache on closing the dialog -> after re-showing or showing freshly created one, we expect to be able to reset to the values shown initialy in this dialog. - Delete plugin's config dialog before deleting the plugin object itself, as the config dialog can rely/use other plugin objects and deleting/closing the dialog late after plugin object destroyed can cause problems (invalid memory access).
Updated... re-added emitting the |
Heh.... after next testing -> the settings cache is messing up the config file. There is some deeper problem, here is the difference between pre-existing config file and after the reset button is pressed: --- ../test_panel.conf 2022-03-14 13:32:47.044289979 +0100
+++ ../test1.conf 2022-03-14 13:32:10.396083054 +0100
@@ -4,8 +4,35 @@
panels=panelTest
[mainmenuTest]
+__userfile__=true
alignment=Left
-ownIcon=false
+iconTheme=
+mainmenuTest\alignment=Left
+mainmenuTest\ownIcon=true
+mainmenuTest\showText=true
+mainmenuTest\type=mainmenu
+ownIcon=true
+panelTest\alignment=0
+panelTest\animation-duration=500
+panelTest\background-color=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
+panelTest\background-image=
+panelTest\desktop=0
+panelTest\font-color=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
+panelTest\hidable=false
+panelTest\hide-on-overlap=false
+panelTest\iconSize=32
+panelTest\lineCount=2
+panelTest\lockPanel=false
+panelTest\opacity=100
+panelTest\panelSize=80
+panelTest\plugins=mainmenuTest
+panelTest\position=Right
+panelTest\reserve-space=false
+panelTest\show-delay=500
+panelTest\visible-margin=false
+panelTest\width=80
+panelTest\width-percent=true
+panels=panelTest
showText=true
type=mainmenu
|
Yes, there is a problem, without this patch too. |
The problem doesn't affect the functionality but makes a mess in |
It's in |
The bug was in liblxqt. → lxqt/liblxqt#306 |
Without calling the beginGroup() on parent settings object, we got the cache object constructed with all keys in the parent object (not only those belonging to our group). Then doing loadFromCache() flushed all keys from config and messed the configuration file.
Not only there... also in the |
How? I can't reproduce the bug with lxqt/liblxqt#306 — and without this patch. |
The logic was very simple. |
Yes, because there is the |
Could you please be more specific about it? Which "sleeping bug"? |
Try to create |
Yes, but 1, It has no effect (after lxqt/liblxqt#306) and |
That's the only point of the "cache". Restore the previously stored configuration snapshot. |
Yes, because there is a |
If there's no OK/Apply button, yes, because the user knows settings should be applied on-the-fly. With OK and Apply buttons, we don't want to save anything before pressing them. Are we prohibiting the usage of OK/Apply buttons here? Sorry if I've misread the code — I'm very busy with other codes now — but I ask because I want to be sure. |
No we're not prohibiting anything, but encouraging the unified on-they-fly updating. If the plugin wants to force ok/apply/cancel it needs to implement it by itself. |
Sorry, however I look at it, I can't find a problem with |
OK, coming back to this — free from other codes. It doesn't prevent a "sleeping bug" but fixes an existing bug, which isn't related to what is fixed in lxqt/liblxqt#306. Previously (a few hours ago), it also worked around the problem that's now fixed in lxqt/liblxqt#306. That was the source of my confusion: the workaround isn't needed anymore but the fix is. What does it fix? The settings cache might not be correct the second time a config dialog was opened. This patch guarantees a correct cache. This wasn't a future bug but an existing one ;) It addition, it discourages Apply/OK buttons (I don't like that but it's beside the point). Three changes in a single PR (actually 4)! Feel free to merge it as it is. I'll need it to be merged for fixing #1741 and changing its previous fixes according to it (perhaps, in a single PR). |
I know, this is a messy PR (shame on me :) ).... I was adding commits here as I was diving deeper into it and finding smelly pieces of code. |
It's OK. I'll follow you in future ;) Who has time for several PRs? |
Should I wait for stefonarch to test this before merging? |
I don't think he'll find a difference, because of the PRs that have been already merged (and I should change them after this is merged). |
OK... merged. Thanks for reviewing. |
i've not followed this, but looking at my panel,conf I wonder why it has 6000 lines and a size of 290kb. |
Because of the bug that's fixed in lxqt/liblxqt#306. Fortunately, most users didn't notice it. EDIT: Or one can say, "Unfortunately....". |
I always was wondering about this file, I think it kept also stuff from testing panels but looking at it is impossible. |
I'd seen the problem before but, because of it, I backed up my panel's conf file in its best state. That, in turn, made me forget about the problem (I restored the backup without taking a look at the config file). |
Reconfigured all, now it makes sense looking at it. Excerpt from the old file:
`` |
Yes, that's prevented both in lxqt/liblxqt#306 and here. The main usefulness of this PR was elsewhere. |
It's hard to describe but, in short, the PR guarantees remembering of the old settings the next time you open the config dialog (of Taskbar). The rest isn't so visible to the user. |
Add emitting settingsChanged() into PluginSettings::loadFromCache() to
notify plugin/users, that settings were updated. Previously the signal
was probably emitted by the underlying object detecting the settings
file changed, but this is not the case any more (probably enhancement
in the underlying Qt's QSettings optimization).
Add PlutingSettings::storeToCache() for the plugin configure dialog to
be able to store to cache on closing the dialog -> after re-showing or
showing freshly created one, we expect to be able to reset to the
values shown initialy in this dialog.
Delete plugin's config dialog before deleting the plugin object
itself, as the config dialog can rely/use other plugin objects and
deleting/closing the dialog late after plugin object destroyed can
cause problems (invalid memory access).
closes #1741