[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47402] trunk/blender/source/blender/ blenloader/intern/readfile.c: Fix for recent library linking fix, this triggered another issue that was

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jun 4 14:01:50 CEST 2012


Revision: 47402
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47402
Author:   blendix
Date:     2012-06-04 12:01:49 +0000 (Mon, 04 Jun 2012)
Log Message:
-----------
Fix for recent library linking fix, this triggered another issue that was
hidden by libraries getting loaded twice, hopefully it's working ok now,
tested with various .blend files.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2012-06-04 11:59:46 UTC (rev 47401)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2012-06-04 12:01:49 UTC (rev 47402)
@@ -7859,10 +7859,17 @@
 					
 					/* Update: the issue is that in file reading, the oldnewmap is OK, but for existing data, it has to be
 					 * inserted in the map to be found! */
-					if (id->flag & LIB_PRE_EXISTING)
-						oldnewmap_insert(fd->libmap, bhead->old, id, 1);
+
+					/* Update: previously it was checking for id->flag & LIB_PRE_EXISTING, however that does not affect file
+					 * reading. For file reading we may need to insert it into the libmap as well, because you might have
+					 * two files indirectly linking the same datablock, and in that case we need this in the libmap for the
+					 * fd of both those files.
+					 *
+					 * The crash that this check avoided earlier was because bhead->code wasn't properly passed in, making
+					 * change_idid_adr not detect the mapping was for an ID_ID datablock. */
+					oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
+					change_idid_adr_fd(fd, bhead->old, id);
 					
-					change_idid_adr_fd(fd, bhead->old, id);
 					// commented because this can print way too much
 					// if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
 				}
@@ -7878,7 +7885,7 @@
 			else {
 				/* this is actually only needed on UI call? when ID was already read before, and another append
 				 * happens which invokes same ID... in that case the lookup table needs this entry */
-				oldnewmap_insert(fd->libmap, bhead->old, id, 1);
+				oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
 				// commented because this can print way too much
 				// if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
 			}
@@ -8763,7 +8770,7 @@
 				else {
 					/* already linked */
 					printf("append: already linked\n");
-					oldnewmap_insert(fd->libmap, bhead->old, id, 1);
+					oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
 					if (id->flag & LIB_INDIRECT) {
 						id->flag -= LIB_INDIRECT;
 						id->flag |= LIB_EXTERN;




More information about the Bf-blender-cvs mailing list