diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-08-18 12:18:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-08-18 12:18:55 +0300 |
commit | 9f25b2f278c3c5609828d5ac780c9f8dbadd9be2 (patch) | |
tree | 49a311388f95640a99099c2f98491c65215d93a7 /source | |
parent | 4d71579d3ba21ed1e51fc7c2d03e2d87f0327d77 (diff) | |
parent | 4c22343271966752094b1e64af45fc5a5c6109b9 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 38 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 2 | ||||
-rw-r--r-- | source/creator/creator_args.c | 18 |
4 files changed, 58 insertions, 3 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 45f6e188483..39364ee27be 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -82,6 +82,9 @@ typedef struct wmGizmoMap wmGizmoMap; typedef struct wmGizmoMapType wmGizmoMapType; /* general API */ +void WM_init_state_app_template_set(const char *app_template); +const char *WM_init_state_app_template_get(void); + void WM_init_state_size_set (int stax, int stay, int sizx, int sizy); void WM_init_state_fullscreen_set(void); void WM_init_state_normal_set(void); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e44081bef54..196e6cfa5ce 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -668,6 +668,33 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) } +struct { + char app_template[64]; + bool override; +} wm_init_state_app_template = {0}; + +/** + * Used for setting app-template from the command line: + * - non-empty string: overrides. + * - empty string: override, using no app template. + * - NULL: clears override. + */ +void WM_init_state_app_template_set(const char *app_template) +{ + if (app_template) { + STRNCPY(wm_init_state_app_template.app_template, app_template); + wm_init_state_app_template.override = true; + } + else { + wm_init_state_app_template.app_template[0] = '\0'; + wm_init_state_app_template.override = false; + } +} + +const char *WM_init_state_app_template_get(void) +{ + return wm_init_state_app_template.override ? wm_init_state_app_template.app_template : NULL; +} /** * Called on startup, (context entirely filled with NULLs) @@ -776,7 +803,10 @@ int wm_homefile_read( } if ((app_template != NULL) && (app_template[0] != '\0')) { - BKE_appdir_app_template_id_search(app_template, app_template_system, sizeof(app_template_system)); + if (!BKE_appdir_app_template_id_search(app_template, app_template_system, sizeof(app_template_system))) { + /* Can safely continue with code below, just warn it's not found. */ + BKE_reportf(reports, RPT_WARNING, "Application Template '%s' not found.", app_template); + } /* Insert template name into startup file. */ @@ -1672,9 +1702,13 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op) /* Always load preferences when switching templates. */ use_userdef = true; + + /* Turn override off, since we're explicitly loading a different app-template. */ + WM_init_state_app_template_set(NULL); } else { - app_template = NULL; + /* Normally NULL, only set when overriding from the command-line. */ + app_template = WM_init_state_app_template_get(); } if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, use_userdef, filepath, app_template)) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 4b0d751a7ce..719544403dd 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -250,7 +250,7 @@ void WM_init(bContext *C, int argc, const char **argv) WM_msgbus_types_init(); /* get the default database, plus a wm */ - wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, NULL); + wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, WM_init_state_app_template_get()); BLT_lang_set(NULL); diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 283585598bf..5e9cec660e1 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -565,6 +565,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo printf("\n"); printf("Misc Options:\n"); + BLI_argsPrintArgDoc(ba, "--app-template"); BLI_argsPrintArgDoc(ba, "--factory-startup"); printf("\n"); BLI_argsPrintArgDoc(ba, "--env-system-datafiles"); @@ -974,6 +975,22 @@ static int arg_handle_debug_fpe_set(int UNUSED(argc), const char **UNUSED(argv), return 0; } +static const char arg_handle_app_template_doc[] = +"\n\tSet the application template, use 'default' for none." +; +static int arg_handle_app_template(int argc, const char **argv, void *UNUSED(data)) +{ + if (argc > 1) { + const char *app_template = STREQ(argv[1], "default") ? "" : argv[1]; + WM_init_state_app_template_set(app_template); + return 1; + } + else { + printf("\nError: App template must follow '--app-template'.\n"); + return 0; + } +} + static const char arg_handle_factory_startup_set_doc[] = "\n\tSkip reading the " STRINGIFY(BLENDER_STARTUP_FILE) " in the users home directory." ; @@ -1898,6 +1915,7 @@ void main_args_setup(bContext *C, bArgs *ba) BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL); + BLI_argsAdd(ba, 1, NULL, "--app-template", CB(arg_handle_app_template), NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL); /* TODO, add user env vars? */ |