[Bf-blender-cvs] [399fd54f88c] blender2.7: Undo System: apply accumulation steps

Campbell Barton noreply at git.blender.org
Wed Jan 9 22:08:01 CET 2019


Commit: 399fd54f88c844a52d3879eb70d99e04d1672582
Author: Campbell Barton
Date:   Wed Jan 9 20:21:24 2019 +1100
Branches: blender2.7
https://developer.blender.org/rB399fd54f88c844a52d3879eb70d99e04d1672582

Undo System: apply accumulation steps

Apply steps between the active and the undo state being decoded.

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

M	source/blender/blenkernel/intern/undo_system.c

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

diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 0ebfb4065e4..04f969c403e 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -552,14 +552,28 @@ bool BKE_undosys_step_undo_with_data_ex(
 		undosys_stack_validate(ustack, true);
 	}
 	UndoStep *us_prev = us ? us->prev : NULL;
-	if (us && us->type->mode == BKE_UNDOTYPE_MODE_STORE) {
+	if (us) {
 		/* The current state is a copy, we need to load the previous state. */
 		us = us_prev;
 	}
 
 	if (us != NULL) {
 		CLOG_INFO(&LOG, 1, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name);
-		undosys_step_decode(C, us, -1);
+
+		/* Handle accumulate steps. */
+		if (ustack->step_active) {
+			UndoStep *us_iter = ustack->step_active;
+			while (us_iter != us) {
+				if (us_iter->type->mode == BKE_UNDOTYPE_MODE_ACCUMULATE) {
+					undosys_step_decode(C, us_iter, -1);
+				}
+				us_iter = us_iter->prev;
+			}
+		}
+
+		if (us->type->mode != BKE_UNDOTYPE_MODE_ACCUMULATE) {
+			undosys_step_decode(C, us, -1);
+		}
 		ustack->step_active = us_prev;
 		undosys_stack_validate(ustack, true);
 		if (use_skip) {
@@ -600,6 +614,19 @@ bool BKE_undosys_step_redo_with_data_ex(
 
 	if (us != NULL) {
 		CLOG_INFO(&LOG, 1, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name);
+
+		/* Handle accumulate steps. */
+		if (ustack->step_active && ustack->step_active->next) {
+			UndoStep *us_iter = ustack->step_active->next;
+			while (us_iter != us) {
+				if (us_iter->type->mode == BKE_UNDOTYPE_MODE_ACCUMULATE) {
+					undosys_step_decode(C, us_iter, 1);
+				}
+				us_iter = us_iter->next;
+			}
+		}
+
+		/* Unlike undo, always redo accumulation state. */
 		undosys_step_decode(C, us, 1);
 		ustack->step_active = us_next;
 		if (use_skip) {



More information about the Bf-blender-cvs mailing list