diff options
author | Bastien Montagne <bastien@blender.org> | 2020-09-14 15:55:48 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-09-16 15:31:46 +0300 |
commit | a4be38c0650bb4006b5c5b2d517503f904de5ed8 (patch) | |
tree | 45516d18f2764880a70571a0224101f6d0b70245 /source | |
parent | 46bdfcab10fad857baffdbcfc1179838aed5660d (diff) |
Fix T78392: [2.83.5, 2.90, 2.91] Crash on undo/ redo after changing modes.
During undo/redo read code is expected to clear the `OB_MODE_EDIT`
bitflag of `Object.mode`, for some reasons.
This was not done anymore for re-used Objects, we need to add a special
handling case for that too.
Should be backported to 2.90 and 2.83 (will probably not be straight
forward for the latter).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c3cfaa8561f..630ead642a3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9585,6 +9585,9 @@ static void read_libblock_undo_restore_identical( if (ob->proxy != NULL) { ob->proxy->proxy_from = ob; } + /* For undo we stay in object mode during undo presses, so keep editmode disabled for re-used + * data-blocks too. */ + ob->mode &= ~OB_MODE_EDIT; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d3052d9919c..60e9cef866e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1902,10 +1902,17 @@ static void write_shaderfxs(WriteData *wd, ListBase *fxbase) static void write_object(WriteData *wd, Object *ob, const void *id_address) { - if (ob->id.us > 0 || wd->use_memfile) { + const bool is_undo = wd->use_memfile; + if (ob->id.us > 0 || is_undo) { /* Clean up, important in undo case to reduce false detection of changed datablocks. */ BKE_object_runtime_reset(ob); + if (is_undo) { + /* For undo we stay in object mode during undo presses, so keep editmode disabled on save as + * well, can help reducing false detection of changed datablocks. */ + ob->mode &= ~OB_MODE_EDIT; + } + /* write LibData */ writestruct_at_address(wd, ID_OB, Object, 1, id_address, ob); write_iddata(wd, &ob->id); |