[Bf-blender-cvs] [9a35ebc] blender-v2.78-release: Fix two issues related to 'partial' .blend files:

Bastien Montagne noreply at git.blender.org
Wed Sep 14 11:42:14 CEST 2016


Commit: 9a35ebc1ea81792747b9037239f4e9b0c377edd8
Author: Bastien Montagne
Date:   Wed Sep 14 11:35:16 2016 +0200
Branches: blender-v2.78-release
https://developer.blender.org/rB9a35ebc1ea81792747b9037239f4e9b0c377edd8

Fix two issues related to 'partial' .blend files:

I) Filename was not put in temp Main generated to save selected data only,
this was breaking readcode when trying to open partial file, leading to missing
filename in final loaded Main data.

II) Read code would confuse partial .blend files with Undo ones, when they had no screen in them
(which happens to 99.999% of partial .blend files I guess).

Reported by @sybren, thanks.

Should be safe enough for 2.78 release.

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

M	source/blender/blenkernel/intern/blendfile.c

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

diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index bedf262..94f762f 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -121,7 +121,12 @@ static void setup_app_data(
 		LOAD_UNDO,
 	} mode;
 
-	if (BLI_listbase_is_empty(&bfd->main->screen)) {
+	/* may happen with library files - UNDO file should never have NULL cursccene... */
+	if (ELEM(NULL, bfd->curscreen, bfd->curscene)) {
+		BKE_report(reports, RPT_WARNING, "Library file, loading empty scene");
+		mode = LOAD_UI_OFF;
+	}
+	else if (BLI_listbase_is_empty(&bfd->main->screen)) {
 		mode = LOAD_UNDO;
 	}
 	else if (G.fileflags & G_FILE_NO_UI) {
@@ -131,14 +136,6 @@ static void setup_app_data(
 		mode = LOAD_UI;
 	}
 
-	if (mode != LOAD_UNDO) {
-		/* may happen with library files */
-		if (ELEM(NULL, bfd->curscreen, bfd->curscene)) {
-			BKE_report(reports, RPT_WARNING, "Library file, loading empty scene");
-			mode = LOAD_UI_OFF;
-		}
-	}
-
 	/* Free all render results, without this stale data gets displayed after loading files */
 	if (mode != LOAD_UNDO) {
 		RE_FreeAllRenderResults();
@@ -511,6 +508,10 @@ bool BKE_blendfile_write_partial(
 	void     *path_list_backup = NULL;
 	const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
 
+	/* This is needed to be able to load that file as a real one later
+	 * (otherwise main->name will not be set at read time). */
+	BLI_strncpy(bmain_dst->name, filepath, sizeof(bmain_dst->name));
+
 	if (write_flags & G_FILE_RELATIVE_REMAP) {
 		path_list_backup = BKE_bpath_list_backup(bmain_src, path_list_flag);
 	}




More information about the Bf-blender-cvs mailing list