Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-05-14 07:58:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-05-14 08:18:51 +0300
commit1cbc3a8f2b4772a96f173083e3a7b32b33b96f0b (patch)
tree827fe99ab835155fd01172be1e9e63351e932b48 /source/blender/editors/undo/ed_undo.c
parent0cd9b1243cd8d06a68cce7419047fec6b18cfc09 (diff)
Fix undo-push assert for some modes with zero undo steps
Also fixes files not being tagged as modified with zero undo steps.
Diffstat (limited to 'source/blender/editors/undo/ed_undo.c')
-rw-r--r--source/blender/editors/undo/ed_undo.c21
1 files changed, 15 insertions, 6 deletions
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();
}
/**