Apply the settings for extensions after import, but before setup() (#1484)

This commit is contained in:
da3dsoul 2023-04-24 23:23:11 -04:00 committed by GitHub
parent b0ce750d4e
commit ebca3f86d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,18 @@ available_extensions = []
setup_called = set()
def apply_settings(extension, name):
if not hasattr(extension, 'params'):
return
for param in extension.params:
_id = f"{name}-{param}"
if _id not in shared.settings:
continue
extension.params[param] = shared.settings[_id]
def load_extensions():
global state, setup_called
for i, name in enumerate(shared.args.extensions):
@ -22,6 +34,7 @@ def load_extensions():
extension = getattr(extensions, name).script
if extension not in setup_called and hasattr(extension, "setup"):
setup_called.add(extension)
apply_settings(extension, name)
extension.setup()
state[name] = [True, i]
@ -105,18 +118,11 @@ def apply_extensions(typ, *args, **kwargs):
def create_extensions_block():
global setup_called
# Updating the default values
for extension, name in iterator():
if hasattr(extension, 'params'):
for param in extension.params:
_id = f"{name}-{param}"
if _id in shared.settings:
extension.params[param] = shared.settings[_id]
should_display_ui = False
for extension, name in iterator():
if hasattr(extension, "ui"):
should_display_ui = True
break
# Creating the extension ui elements
if should_display_ui: