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.
This commit is contained in:
Brecht Van Lommel 2012-06-04 12:01:49 +00:00
parent 0f2b4d4dff
commit 9a488fd8b8

@ -7859,10 +7859,17 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
/* 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);
// 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 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
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 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons
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;