Changing Setting in a Plugin

v2

I want to change some setting with my plugin because they are required for the functionality that my plugin is aiming to provide. (I would be happy and even prefer to do it all with hooks but as far as I can tell there is no way of doing so). The settings are preserved_tags, clear_existing_tags, and move_additional_files_pattern. When I make a change (as shown below) it registers the change in the sense that when I query I receive the new value. However, the value shown inside of the app’s settings page does not update until I quit & reopen the app. I do not want to have to do that. How can I get the changes to become effective immediately after changing them.

Thanks

config.setting["clear_existing_tags"] = True

log.error(config.setting["clear_existing_tags"])

Hard to say what’s happening without seeing the plugin code and where exactly you are changing the settings. Generally settings changes are directly available.

If you are setting this as part of the options UI it might be that the main option page overwrites the value again on save.

Also changing this specific setting has no impact on already loaded data unless you reload the releases.

1 Like

I mean it really is just about as simple as those two lines. I have a function which contains those lines. That function is called by the main flow without conditions. So, whenever the plugin is installed / turned on, the config changes should be made.

In my testing I have been adding files after it should have already taken place. I am not currently setting it as part of the options UI (though, I do intend to move it there in part).

From the description I assume this is a Picard 2 plugin (for the current stable version).

The v2 plugins do not really have a main flow, nothing that gets called when the plugin gets enabled.

So your setting code is either in one of the hooks, where it would only be executed when this hook gets called, or actually executed as part of the module code on load.

I suspect that’s the case here. Which will not behave as you likely expect. In Picard 2 all installed modules, no matter if enabled or not will be loaded and executed on program start. Which would explain why the setting is set after a fresh start of Picard.

That’s one issue (among several others) we addressed with the new plugin system for v3, where plugins only get loaded if they are enabled and there is an explitit enabled hook being called everytime the plugin gets enabled.

2 Likes