diff options
-rw-r--r-- | release/scripts/modules/bl_app_template_utils.py | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/release/scripts/modules/bl_app_template_utils.py b/release/scripts/modules/bl_app_template_utils.py index 42467d21580..6ee1e2ab8df 100644 --- a/release/scripts/modules/bl_app_template_utils.py +++ b/release/scripts/modules/bl_app_template_utils.py @@ -170,10 +170,6 @@ def activate(template_id=None): if template_id_prev: _disable(template_id_prev) - # Disable all addons, afterwards caller must reset. - import addon_utils - addon_utils.disable_all() - # ignore_not_found so modules that don't contain scripts don't raise errors _mod = _enable(template_id, ignore_not_found=True) if template_id else None diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 41cc00a3e3f..d278cafb821 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -846,6 +846,21 @@ void wm_homefile_read(bContext *C, SET_FLAG_FROM_TEST(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_FLAG_SCRIPT_AUTOEXEC); } + if (use_userdef || reset_app_template) { +#ifdef WITH_PYTHON + /* This only runs once Blender has already started. */ + if (CTX_py_init_get(C)) { + /* This is restored by 'wm_file_read_post', disable before loading any preferences + * so an add-on can read their own preferences when un-registering, + * and use new preferences if/when re-registering, see T67577. + * + * Note that this fits into 'wm_file_read_pre' function but gets messy + * since we need to know if 'reset_app_template' is true. */ + BPY_execute_string(C, (const char *[]){"addon_utils", NULL}, "addon_utils.disable_all()"); + } +#endif /* WITH_PYTHON */ + } + wm_file_read_pre(C, use_data, use_userdef); if (use_data) { |