diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-09-02 10:44:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-09-02 10:50:20 +0300 |
commit | cf67ba848f2f42e0b7320aa0654ba89bd14a1416 (patch) | |
tree | aaaa53892f644aa4135274f200111daefb0e8f4e /source | |
parent | 428a1aaf7372aaad793fe7cc03128db18e3ae602 (diff) |
WM: add use_factory_startup option to read homefile operator
There was no way to reset the current file to factory settings
without reloading the preferences (which disables & re-enables add-ons),
this slows down resetting files and can complicate tests.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f53a3d6bf35..561e27f933d 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1982,7 +1982,10 @@ void WM_OT_read_history(wmOperatorType *ot) static int wm_homefile_read_exec(bContext *C, wmOperator *op) { - const bool use_factory_settings = (STREQ(op->type->idname, "WM_OT_read_factory_settings")); + const bool use_factory_startup_and_userdef = STREQ(op->type->idname, + "WM_OT_read_factory_settings"); + const bool use_factory_settings = use_factory_startup_and_userdef || + RNA_boolean_get(op->ptr, "use_factory_startup"); bool use_userdef = false; char filepath_buf[FILE_MAX]; const char *filepath = NULL; @@ -2007,10 +2010,12 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op) } } else { - /* always load UI for factory settings (prefs will re-init) */ - G.fileflags &= ~G_FILE_NO_UI; - /* Always load preferences with factory settings. */ - use_userdef = true; + if (use_factory_startup_and_userdef) { + /* always load UI for factory settings (prefs will re-init) */ + G.fileflags &= ~G_FILE_NO_UI; + /* Always load preferences with factory settings. */ + use_userdef = true; + } } char app_template_buf[sizeof(U.app_template)]; @@ -2127,6 +2132,12 @@ void WM_OT_read_homefile(wmOperatorType *ot) prop = RNA_def_boolean(ot->srna, "use_splash", false, "Splash", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + /* So scripts can load factory-startup without resetting preferences + * (which has other implications such as reloading all add-ons). + * Match naming for `--factory-startup` command line argument. */ + prop = RNA_def_boolean(ot->srna, "use_factory_startup", false, "Factory Startup", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + read_homefile_props(ot); /* omit poll to run in background mode */ |