UndoSystem: Early out from core undo/redo handlers when undo step is NULL.

Also added `undosys_stack_validate` debug check to redo case.
This commit is contained in:
Bastien Montagne 2021-01-07 12:15:22 +01:00
parent 044dd42a05
commit 4c0fc60105
1 changed files with 9 additions and 2 deletions

View File

@ -675,9 +675,11 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
bool use_skip)
{
UNDO_NESTED_ASSERT(false);
if (us) {
undosys_stack_validate(ustack, true);
if (us == NULL) {
return false;
}
undosys_stack_validate(ustack, true);
UndoStep *us_prev = us ? us->prev : NULL;
if (us) {
/* The current state is a copy, we need to load the previous state. */
@ -753,6 +755,11 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
bool use_skip)
{
UNDO_NESTED_ASSERT(false);
if (us == NULL) {
return false;
}
undosys_stack_validate(ustack, true);
UndoStep *us_next = us ? us->next : NULL;
/* Unlike undo accumulate, we always use the next. */
us = us_next;