Information Settings not saved when using __settings__.setSetting('setting', 'value')
#1
This has been bugging me for some time so I thought I would ask.

Why is it when you use  __settings__.setSetting('setting', 'value') in a python script it will set the setting with a new value and use the new value when using say xxx = __settings__.getSetting('setting') in other places in your script while the app is still running but as soon as you close your app and reopen it, the value of the setting you changed while running your app previously does not hold. It reverts back to the value it was before opening your app or the value you set it to from the context menu of the app before opening it. The only way to make the value hold is if you set the setting before opening your app.

How can I make the setting that is changed from a python script to save and be the same if I close my app and reopen it?
Reply
#2
Without knowing what your __settings__ actually is and how/when it is created, it is difficult to say what could be wrong, but I suspect the issue is that you are treating it is as a singleton when it is not.

If you have created a __settings__ instance that is subsequently used for calling getSettings, prior to using setSetting on another __settings__ instance, then the original __settings__ instance will not reflect the updated setting value from the second __settings__ instance. If your first __settings__ instance subsequently causes settings to be saved, then the changed value from your second __settings__ instance will be lost.

After the setting is updated by your second __settings__ instance, if you create a new __settings__ instance to replace the first __settings__ instance then it will have the updated value.
Reply

Logout Mark Read Team Forum Stats Members Help
Settings not saved when using __settings__.setSetting('setting', 'value')0