[Bf-blender-cvs] [1a69384e76e] master: Fix T74205: crash cancelling transfrom operation in sculpt mode
Asad-ullah Khan
noreply at git.blender.org
Fri Apr 3 13:15:45 CEST 2020
Commit: 1a69384e76e2b1ab11c87a582eb2cdf26386ac59
Author: Asad-ullah Khan
Date: Fri Apr 3 02:35:25 2020 +0200
Branches: master
https://developer.blender.org/rB1a69384e76e2b1ab11c87a582eb2cdf26386ac59
Fix T74205: crash cancelling transfrom operation in sculpt mode
Differential Revision: https://developer.blender.org/D7018
===================================================================
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8d4870f5dd8..db138bb907d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -11076,7 +11076,11 @@ void ED_sculpt_end_transform(struct bContext *C)
if (ss->filter_cache) {
sculpt_filter_cache_free(ss);
}
- SCULPT_undo_push_end();
+ /* Force undo push to happen even inside transform operator, since the sculpt
+ * undo system works separate from regular undo and this is require to properly
+ * finish an undo step also when cancelling. */
+ const bool use_nested_undo = true;
+ SCULPT_undo_push_end_ex(use_nested_undo);
sculpt_flush_update_done(C, ob, SCULPT_UPDATE_COORDS);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index f0481582571..60b51ce17fd 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -726,6 +726,7 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node);
void SCULPT_undo_push_begin(const char *name);
void SCULPT_undo_push_end(void);
+void SCULPT_undo_push_end_ex(const bool use_nested_undo);
void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index f6ed4fa21e0..f21bfe245dd 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1289,6 +1289,11 @@ void SCULPT_undo_push_begin(const char *name)
}
void SCULPT_undo_push_end(void)
+{
+ SCULPT_undo_push_end_ex(false);
+}
+
+void SCULPT_undo_push_end_ex(const bool use_nested_undo)
{
UndoSculpt *usculpt = sculpt_undo_get_nodes();
SculptUndoNode *unode;
@@ -1307,7 +1312,7 @@ void SCULPT_undo_push_end(void)
/* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */
wmWindowManager *wm = G_MAIN->wm.first;
- if (wm->op_undo_depth == 0) {
+ if (wm->op_undo_depth == 0 || use_nested_undo) {
UndoStack *ustack = ED_undo_stack_get();
BKE_undosys_step_push(ustack, NULL, NULL);
WM_file_tag_modified();
More information about the Bf-blender-cvs
mailing list