[Bf-blender-cvs] [d8b0b8d3db6] master: New Undo: Fix crash in some complex production files.

Bastien Montagne noreply at git.blender.org
Fri Apr 3 16:10:51 CEST 2020


Commit: d8b0b8d3db6b2953db33d80390f1789f8700e145
Author: Bastien Montagne
Date:   Fri Apr 3 16:07:27 2020 +0200
Branches: master
https://developer.blender.org/rBd8b0b8d3db6b2953db33d80390f1789f8700e145

New Undo: Fix crash in some complex production files.

There is no guarantee that depsgraph is ran between two undo steps, so
when re-using an existing data-block we should never wipe completly its
recalc flags, but instead complement them with new ones from accumulated
'storage' as needed.

===================================================================

M	source/blender/blenloader/intern/readfile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6bc920c26f9..739c816ad45 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9418,19 +9418,21 @@ static BHead *read_libblock(FileData *fd,
           if (do_partial_undo) {
             /* Even though we re-use the old ID as-is, it does not mean that we are 100% safe from
              * needing some depsgraph updates for it (it could depend on another ID which address
-             * did
-             * not change, but which actual content might have been re-read from the memfile). */
+             * did not change, but which actual content might have been re-read from the memfile).
+             * IMPORTANT: Do not fully overwrite recalc flag here, depsgraph may not have been ran
+             * yet for previous undo step(s), we do not want to erase flags set by those.
+             */
             if (fd->undo_direction < 0) {
               /* We are coming from the future (i.e. do an actual undo, and not a redo), we use our
                * old reused ID's 'accumulated recalc flags since last memfile undo step saving' as
                * recalc flags. */
-              id_old->recalc = id_old->recalc_undo_accumulated;
+              id_old->recalc |= id_old->recalc_undo_accumulated;
             }
             else {
               /* We are coming from the past (i.e. do a redo), we use the saved 'accumulated recalc
                * flags since last memfile undo step saving' from the newly read ID as recalc flags.
                */
-              id_old->recalc = id->recalc_undo_accumulated;
+              id_old->recalc |= id->recalc_undo_accumulated;
             }
             /* There is no need to flush the depsgraph's CoWs here, since that ID's data itself did
              * not change. */



More information about the Bf-blender-cvs mailing list