From 2e487ec92ec79fbc3353b9933ec2977ef0980aa6 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Tue, 16 Jul 2024 21:27:11 +0200 Subject: [PATCH] Fix #124484: Debug assert on undoing out of Sculpt Mode While this is a rather fragile fix, the alternative also seems fragile. We can instead check the operator name inside `push_begin_ex` to see if the operator is transitioning into Sculpt Mode and initialize the StepData.type to a custom "Mode Change" type instead of using "None" Pull Request: https://projects.blender.org/blender/blender/pulls/124640 --- source/blender/editors/sculpt_paint/sculpt_undo.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index 4278ca2494d..e4af44daac1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -911,6 +911,12 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) return; } + /* Switching to sculpt mode does not push a particular type. + * See #124484. */ + if (step_data.type == Type::None && step_data.nodes.is_empty()) { + return; + } + const bool tag_update = ID_REAL_USERS(object.data) > 1 || !BKE_sculptsession_use_pbvh_draw(&object, rv3d) || ss.shapekey_active || ss.deform_modifiers_active;