diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-03 07:34:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-03 07:46:52 +0300 |
commit | f0df4d6c35fc17c57adc8c0bcd5af11f7583f2ee (patch) | |
tree | cfc5d6ee12c9368978947bbde4006e66ab36e5df /source/blender/windowmanager | |
parent | 2749e6a639e084931af944b046a044582bd7a15e (diff) |
Fix T67577: Add-on unregister can't access preferences on factory reset
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 15 |
1 files changed, 15 insertions, 0 deletions
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) { |