From 76cc8e8436875c1c700d6a7d29d3cffeddc04c7d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Apr 2021 19:30:31 +1000 Subject: Fix T85974: Edit-mode undo/redo causes assertion Without legacy-undo, loading memfile undo only cleared edit-mode data for mesh and armature object types. This causes an assertion when loading edit-mode undo steps afterwards for other object types as the existence of this data made entering object mode fail. Resolve this by freeing all objects types undo data from ED_editors_exit --- source/blender/editors/util/ed_util.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'source/blender/editors/util') diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index da94eef4917..b80782b51be 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -27,9 +27,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_armature_types.h" -#include "DNA_mesh_types.h" - #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -206,24 +203,9 @@ void ED_editors_exit(Main *bmain, bool do_undo_system) * * To reproduce the problem where stale data is used, see: T84920. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - if (ob->type == OB_MESH) { - Mesh *me = ob->data; - if (me->edit_mesh) { - EDBM_mesh_free(me->edit_mesh); - MEM_freeN(me->edit_mesh); - me->edit_mesh = NULL; - if (do_undo_system == false) { - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - } - } - } - else if (ob->type == OB_ARMATURE) { - bArmature *arm = ob->data; - if (arm->edbo) { - ED_armature_edit_free(ob->data); - if (do_undo_system == false) { - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - } + if (ED_object_editmode_free_ex(bmain, ob)) { + if (do_undo_system == false) { + DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); } } } -- cgit v1.2.3