[Bf-blender-cvs] [1cbc3a8f2b4] blender-v2.83-release: Fix undo-push assert for some modes with zero undo steps

Campbell Barton noreply at git.blender.org
Thu May 14 07:20:34 CEST 2020


Commit: 1cbc3a8f2b4772a96f173083e3a7b32b33b96f0b
Author: Campbell Barton
Date:   Thu May 14 14:58:54 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rB1cbc3a8f2b4772a96f173083e3a7b32b33b96f0b

Fix undo-push assert for some modes with zero undo steps

Also fixes files not being tagged as modified with zero undo steps.

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

M	source/blender/editors/undo/ed_undo.c

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

diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index f7300221028..6633e1c427c 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -79,15 +79,26 @@ static CLG_LogRef LOG = {"ed.undo"};
 void ED_undo_push(bContext *C, const char *str)
 {
   CLOG_INFO(&LOG, 1, "name='%s'", str);
+  WM_file_tag_modified();
 
-  const int steps = U.undosteps;
-
+  wmWindowManager *wm = CTX_wm_manager(C);
+  int steps = U.undosteps;
+
+  /* Ensure steps that have been initialized are always pushed,
+   * even when undo steps are zero.
+   *
+   * Note that some modes (paint, sculpt) initialize an undo step before an action runs,
+   * then accumulate changes there, or restore data from it in the case of 2D painting.
+   *
+   * For this reason we need to handle the undo step even when undo steps is set to zero.
+   */
+  if ((steps <= 0) && wm->undo_stack->step_init != NULL) {
+    steps = 1;
+  }
   if (steps <= 0) {
     return;
   }
 
-  wmWindowManager *wm = CTX_wm_manager(C);
-
   /* Only apply limit if this is the last undo step. */
   if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == NULL)) {
     BKE_undosys_stack_limit_steps_and_memory(wm->undo_stack, steps - 1, 0);
@@ -103,8 +114,6 @@ void ED_undo_push(bContext *C, const char *str)
   if (CLOG_CHECK(&LOG, 1)) {
     BKE_undosys_print(wm->undo_stack);
   }
-
-  WM_file_tag_modified();
 }
 
 /**



More information about the Bf-blender-cvs mailing list