[Bf-blender-cvs] [815855b91b9] blender-v2.83-release: Fix T76642: Incorrect behavior limiting undo steps

Campbell Barton noreply at git.blender.org
Mon May 11 14:21:22 CEST 2020


Commit: 815855b91b9525e98894bcc61f6bafb6e205c86f
Author: Campbell Barton
Date:   Mon May 11 22:01:53 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rB815855b91b9525e98894bcc61f6bafb6e205c86f

Fix T76642: Incorrect behavior limiting undo steps

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

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 e776e9bedb0..33a457386e8 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -427,10 +427,6 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
   }
 
   if (us) {
-    if (us->prev && us->prev->prev) {
-      us = us->prev;
-    }
-
 #ifdef WITH_GLOBAL_UNDO_KEEP_ONE
     /* Hack, we need to keep at least one BKE_UNDOSYS_TYPE_MEMFILE. */
     if (us->type != BKE_UNDOSYS_TYPE_MEMFILE) {
@@ -438,6 +434,12 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
       while (us_exclude && us_exclude->type != BKE_UNDOSYS_TYPE_MEMFILE) {
         us_exclude = us_exclude->prev;
       }
+      /* Once this is outside the given number of 'steps', undoing onto this state
+       * may skip past many undo steps which is confusing, instead,
+       * disallow stepping onto this state entirely. */
+      if (us_exclude) {
+        us_exclude->skip = true;
+      }
     }
 #endif
     /* Free from first to last, free functions may update de-duplication info
@@ -672,7 +674,15 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
     us = us_prev;
   }
 
-  if (us != NULL) {
+  /* This will be active once complete. */
+  UndoStep *us_active = us_prev;
+  if (use_skip) {
+    while (us_active && us_active->skip) {
+      us_active = us_active->prev;
+    }
+  }
+
+  if ((us != NULL) && (us_active != NULL)) {
     CLOG_INFO(&LOG, 1, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name);
 
     /* Handle accumulate steps. */
@@ -689,13 +699,6 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
       }
     }
 
-    UndoStep *us_active = us_prev;
-    if (use_skip) {
-      while (us_active->skip && us_active->prev) {
-        us_active = us_active->prev;
-      }
-    }
-
     {
       UndoStep *us_iter = us_prev;
       do {
@@ -744,7 +747,15 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
   /* Unlike undo accumulate, we always use the next. */
   us = us_next;
 
-  if (us != NULL) {
+  /* This will be active once complete. */
+  UndoStep *us_active = us_next;
+  if (use_skip) {
+    while (us_active && us_active->skip) {
+      us_active = us_active->next;
+    }
+  }
+
+  if ((us != NULL) && (us_active != NULL)) {
     CLOG_INFO(&LOG, 1, "addr=%p, name='%s', type='%s'", us, us->name, us->type->name);
 
     /* Handle accumulate steps. */
@@ -756,13 +767,6 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
       }
     }
 
-    UndoStep *us_active = us_next;
-    if (use_skip) {
-      while (us_active->skip && us_active->prev) {
-        us_active = us_active->next;
-      }
-    }
-
     {
       UndoStep *us_iter = us_next;
       do {



More information about the Bf-blender-cvs mailing list