From df7f6a3e2e91a7ad27f8ca2b2b43a6c51da8c2c9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Mar 2017 19:07:21 +1100 Subject: Option to load startup file with empty-data Useful for batch conversion and tests. --- source/blender/windowmanager/intern/wm_files.c | 16 ++++++++++++++-- source/blender/windowmanager/intern/wm_init_exit.c | 2 +- source/blender/windowmanager/wm_files.h | 3 ++- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 27395dbaf3e..2e799307cc0 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -643,7 +643,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) * When not-null, this is written into the user preferences. */ int wm_homefile_read( - bContext *C, ReportList *reports, bool use_factory_settings, + bContext *C, ReportList *reports, + bool use_factory_settings, bool use_empty_data, const char *filepath_startup_override, const char *app_template_override) { ListBase wmbase; @@ -779,6 +780,10 @@ int wm_homefile_read( } } + if (use_empty_data) { + BKE_blendfile_read_make_empty(C); + } + /* Load template preferences, * unlike regular preferences we only use some of the settings, * see: BKE_blender_userdef_set_app_template */ @@ -1551,6 +1556,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op) const char *app_template; PropertyRNA *prop_app_template = RNA_struct_find_property(op->ptr, "app_template"); const bool use_splash = !use_factory_settings && RNA_boolean_get(op->ptr, "use_splash"); + const bool use_empty_data = RNA_boolean_get(op->ptr, "use_empty"); if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) { RNA_property_string_get(op->ptr, prop_app_template, app_template_buf); @@ -1560,7 +1566,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op) app_template = NULL; } - if (wm_homefile_read(C, op->reports, use_factory_settings, filepath, app_template)) { + if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, filepath, app_template)) { if (use_splash) { WM_init_splash(C); } @@ -1591,6 +1597,9 @@ void WM_OT_read_homefile(wmOperatorType *ot) "Load user interface setup from the .blend file"); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + /* So the splash can be kept open after loading a file (for templates). */ prop = RNA_def_boolean(ot->srna, "use_splash", false, "Splash", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); @@ -1615,6 +1624,9 @@ void WM_OT_read_factory_settings(wmOperatorType *ot) prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + /* omit poll to run in background mode */ } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 5483cf25e40..9bafe72d805 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -192,7 +192,7 @@ void WM_init(bContext *C, int argc, const char **argv) wm_init_reports(C); /* get the default database, plus a wm */ - wm_homefile_read(C, NULL, G.factory_startup, NULL, NULL); + wm_homefile_read(C, NULL, G.factory_startup, false, NULL, NULL); BLT_lang_set(NULL); diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 15a94d2da70..9a1518e15b0 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -36,7 +36,8 @@ struct wmOperatorType; /* wm_files.c */ void wm_history_file_read(void); int wm_homefile_read( - struct bContext *C, struct ReportList *reports, bool use_factory_settings, + struct bContext *C, struct ReportList *reports, + bool use_factory_settings, bool use_empty_data, const char *filepath_startup_override, const char *app_template_override); void wm_file_read_report(bContext *C); -- cgit v1.2.3