From b3fc2cd8873b5dcf48c78a437581da46585fb3bb Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 10 Jan 2024 03:48:30 -0800 Subject: [PATCH] UI: Do not save unchanged extension settings to settings.yaml --- modules/extensions.py | 17 ++++++++++------- modules/ui.py | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/extensions.py b/modules/extensions.py index 2a3b0bb1..0af5e5fe 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -19,10 +19,9 @@ def apply_settings(extension, name): for param in extension.params: _id = f"{name}-{param}" - if _id not in shared.settings: - continue - - extension.params[param] = shared.settings[_id] + shared.default_settings[_id] = extension.params[param] + if _id in shared.settings: + extension.params[param] = shared.settings[_id] def load_extensions(): @@ -40,10 +39,14 @@ def load_extensions(): raise extension = getattr(extensions, name).script - apply_settings(extension, name) - if extension not in setup_called and hasattr(extension, "setup"): + + # Only run setup() and apply settings from settings.yaml once + if extension not in setup_called: + apply_settings(extension, name) + if hasattr(extension, "setup"): + extension.setup() + setup_called.add(extension) - extension.setup() state[name] = [True, i] except: diff --git a/modules/ui.py b/modules/ui.py index 176d27a2..3c978225 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -232,7 +232,9 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state): params = getattr(extension, 'params') for param in params: _id = f"{extension_name}-{param}" - output[_id] = params[param] + # Only save if different from default value + if param not in shared.default_settings or params[param] != shared.default_settings[param]: + output[_id] = params[param] # Do not save unchanged settings for key in list(output.keys()):