Fix T48412: Blender 2.77a crashes on Undo in some specific multi-level linked libraries cases.

Good old dead-brain stupid error when iterating over a linked list from which you remove some items...
This commit is contained in:
Bastien Montagne 2016-06-21 16:12:33 +02:00
parent 8dec4a0e79
commit e34ade4eb3
Notes: blender-bot 2023-02-14 07:53:50 +01:00
Referenced by issue #48412, Blender 2.77a crashes on Undo in some specific multi-level linked libraries cases
1 changed files with 3 additions and 2 deletions

View File

@ -411,11 +411,12 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
/* Even though directly used libs have been already moved to new main, indirect ones have not.
* This is a bit annoying, but we have no choice but to keep them all for now - means some now unused
* data may remain in memory, but think we'll have to live with it. */
Main *libmain;
Main *libmain, *libmain_next;
Main *newmain = bfd->main;
ListBase new_mainlist = {newmain, newmain};
for (libmain = oldmain->next; libmain; libmain = libmain->next) {
for (libmain = oldmain->next; libmain; libmain = libmain_next) {
libmain_next = libmain->next;
/* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent
* to detect indirect-linked ones... */
if (libmain->curlib && (libmain->curlib->parent != NULL)) {