[Bf-blender-cvs] [3cd46c5ebc] app-templates: Minor changes, remove force_load_startup

Campbell Barton noreply at git.blender.org
Thu Mar 23 00:19:06 CET 2017


Commit: 3cd46c5ebc440a745167b1243556a34c6f274566
Author: Campbell Barton
Date:   Thu Mar 23 10:19:04 2017 +1100
Branches: app-templates
https://developer.blender.org/rB3cd46c5ebc440a745167b1243556a34c6f274566

Minor changes, remove force_load_startup

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 2b9d8d9a3f..17d4e521d0 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -637,17 +637,17 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
  * \param from_memory: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead.
  * Used for "Restore Factory Settings".
  * \param filepath_startup_override: Optional path pointing to an alternative blend file (may be NULL).
- * \param custom_app_template: Template to use instead of the template defined in user-preferences.
+ * \param app_template_override: Template to use instead of the template defined in user-preferences.
+ * When not-null, this is written into the user preferences.
  */
 int wm_homefile_read(
         bContext *C, ReportList *reports, bool from_memory,
-        const char *filepath_startup_override, const char *custom_app_template)
+        const char *filepath_startup_override, const char *app_template_override)
 {
 	ListBase wmbase;
 	char filepath_startup[FILE_MAX];
 	char filepath_userdef[FILE_MAX];
 	bool success = false;
-	bool force_load_startup = false;
 	/* Indicates whether user preferences were really load from memory.
 	 *
 	 * This is used for versioning code, and for this we can not rely on from_memory
@@ -673,6 +673,9 @@ int wm_homefile_read(
 
 	G.relbase_valid = 0;
 
+	filepath_startup[0] = '\0';
+	filepath_userdef[0] = '\0';
+
 	if (!from_memory) {
 		const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
 		if (cfgdir) {
@@ -680,8 +683,6 @@ int wm_homefile_read(
 			BLI_make_file_string("/", filepath_userdef, cfgdir, BLENDER_USERPREF_FILE);
 		}
 		else {
-			filepath_startup[0] = '\0';
-			filepath_userdef[0] = '\0';
 			from_memory = true;
 		}
 
@@ -709,9 +710,15 @@ int wm_homefile_read(
 
 	/* insert template name into startup file */
 	if (!filepath_startup_override) {
-		const char *app_template =
-		        custom_app_template ? custom_app_template :
-		                              ((!from_memory && U.app_template[0]) ? U.app_template : NULL);
+		const char *app_template = NULL;
+
+		if (app_template_override) {
+			app_template = app_template_override;
+		}
+		else if (!from_memory && U.app_template[0]) {
+			app_template = U.app_template;
+		}
+
 		if (app_template != NULL) {
 			if (!from_memory) {
 				BLI_path_suffix(filepath_startup, sizeof(filepath_startup), app_template, "_");
@@ -722,16 +729,16 @@ int wm_homefile_read(
 				BLI_join_dirfile(temp_path, sizeof(temp_path), "app_templates", U.app_template);
 				const char *filepath_startup_template = BKE_appdir_folder_id(BLENDER_DATAFILES, temp_path);
 				if (filepath_startup_template) {
+					/* note that the path is being set even when 'from_memory == true' */
 					BLI_join_dirfile(
 					        filepath_startup, sizeof(filepath_startup),
 					        filepath_startup_template, BLENDER_STARTUP_FILE);
-					force_load_startup = true;
 				}
 			}
 		}
 	}
 
-	if (!from_memory || force_load_startup) {
+	if (!from_memory || (filepath_startup[0] != '\0')) {
 		if (BLI_access(filepath_startup, R_OK) == 0) {
 			success = (BKE_blendfile_read(C, filepath_startup, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL);
 			if (success) {
@@ -767,8 +774,8 @@ int wm_homefile_read(
 	}
 	
 	/* Load a file but keep the splash open */
-	if (custom_app_template) {
-		BLI_strncpy(U.app_template, custom_app_template, sizeof(U.app_template));
+	if (app_template_override) {
+		BLI_strncpy(U.app_template, app_template_override, sizeof(U.app_template));
 	}
 
 	/* load template preferences */




More information about the Bf-blender-cvs mailing list