From 815855b91b9525e98894bcc61f6bafb6e205c86f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 May 2020 22:01:53 +1000 Subject: Fix T76642: Incorrect behavior limiting undo steps --- source/blender/blenkernel/intern/undo_system.c | 44 ++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') 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 { -- cgit v1.2.3