diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 540eb575d7f..68a2c6c1a2a 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -3637,7 +3637,9 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) Main *old_main = static_cast
(fd->old_mainlist->first); BLI_assert(old_main != nullptr); BLI_assert(old_main->curlib == nullptr); - for (Main *libmain = old_main->next; libmain != nullptr; libmain = libmain->next) { + Main *libmain, *libmain_next; + for (libmain = old_main->next; libmain != nullptr; libmain = libmain_next) { + libmain_next = libmain->next; read_undo_move_libmain_data(fd, new_main, old_main, libmain, nullptr); } } @@ -3676,7 +3678,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) fd->reports->duration.libraries = BLI_time_now_seconds() - fd->reports->duration.libraries; /* Skip in undo case. */ - if ((fd->flags & FD_FLAGS_IS_MEMFILE) == 0) { + if (!is_undo) { /* Note that we can't recompute user-counts at this point in undo case, we play too much with * IDs from different memory realms, and Main database is not in a fully valid state yet. */ @@ -3729,7 +3731,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) /* Now that all our data-blocks are loaded, * we can re-generate overrides from their references. */ - if ((fd->flags & FD_FLAGS_IS_MEMFILE) == 0) { + if (!is_undo) { /* Do not apply in undo case! */ fd->reports->duration.lib_overrides = BLI_time_now_seconds();