[Bf-blender-cvs] [31028339628] master: Fix undo of transform after frame change undoing too much.

Brecht Van Lommel noreply at git.blender.org
Wed Jun 13 19:23:18 CEST 2018


Commit: 3102833962853b1fb0ebd942a1c8111a70eb12bd
Author: Brecht Van Lommel
Date:   Wed Jun 13 18:22:17 2018 +0200
Branches: master
https://developer.blender.org/rB3102833962853b1fb0ebd942a1c8111a70eb12bd

Fix undo of transform after frame change undoing too much.

For grouped undo we should not skip the undo push, rather replace the
previous undo push. This way undo goes back to the state after the last
operation in the group.

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

M	source/blender/blenkernel/BKE_undo_system.h
M	source/blender/blenkernel/intern/undo_system.c
M	source/blender/editors/undo/ed_undo.c

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

diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h
index 05093deec70..a75606a17cb 100644
--- a/source/blender/blenkernel/BKE_undo_system.h
+++ b/source/blender/blenkernel/BKE_undo_system.h
@@ -135,6 +135,7 @@ extern const UndoType *BKE_UNDOSYS_TYPE_TEXT;
 UndoStack      *BKE_undosys_stack_create(void);
 void            BKE_undosys_stack_destroy(UndoStack *ustack);
 void            BKE_undosys_stack_clear(UndoStack *ustack);
+void            BKE_undosys_stack_clear_active(UndoStack *ustack);
 bool            BKE_undosys_stack_has_undo(UndoStack *ustack, const char *name);
 void            BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain);
 void            BKE_undosys_stack_init_from_context(UndoStack *ustack, struct bContext *C);
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index a8f895853ed..ba7d432fab3 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -234,6 +234,23 @@ void BKE_undosys_stack_clear(UndoStack *ustack)
 	ustack->step_active = NULL;
 }
 
+void BKE_undosys_stack_clear_active(UndoStack *ustack)
+{
+	/* Remove active and all following undos. */
+	UndoStep *us = ustack->step_active;
+
+	if (us) {
+		ustack->step_active = us->prev;
+		bool is_not_empty = ustack->step_active != NULL;
+
+		while (ustack->steps.last != ustack->step_active) {
+			UndoStep *us_iter = ustack->steps.last;
+			undosys_step_free_and_unlink(ustack, us_iter);
+			undosys_stack_validate(ustack, is_not_empty);
+		}
+	}
+}
+
 static bool undosys_stack_push_main(UndoStack *ustack, const char *name, struct Main *bmain)
 {
 	UNDO_NESTED_ASSERT(false);
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index d8b194e3336..539d0245306 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -143,15 +143,10 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
 void ED_undo_grouped_push(bContext *C, const char *str)
 {
 	/* do nothing if previous undo task is the same as this one (or from the same undo group) */
-	{
-		wmWindowManager *wm = CTX_wm_manager(C);
-		if (wm->undo_stack->steps.last) {
-			const UndoStep *us = wm->undo_stack->steps.last;
-			if (STREQ(str, us->name)) {
-				return;
-			}
-		}
-
+	wmWindowManager *wm = CTX_wm_manager(C);
+	const UndoStep *us = wm->undo_stack->step_active;
+	if (us && STREQ(str, us->name)) {
+		BKE_undosys_stack_clear_active(wm->undo_stack);
 	}
 
 	/* push as usual */



More information about the Bf-blender-cvs mailing list