diff options
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8710c5fe075..8e9394a886e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -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; |