From 4f69f027efe98ec64c2cacb90ec69489f62b4ba9 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 13 Feb 2022 23:22:48 -0600 Subject: [PATCH] [nostalgia/studio] Make UndoCommand::redo execute as soon as pushed --- src/nostalgia/studio/lib/undostack.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nostalgia/studio/lib/undostack.cpp b/src/nostalgia/studio/lib/undostack.cpp index cbe54356f..c8b4b322a 100644 --- a/src/nostalgia/studio/lib/undostack.cpp +++ b/src/nostalgia/studio/lib/undostack.cpp @@ -12,14 +12,19 @@ void UndoStack::push(UndoCommand *cmd) noexcept { } m_stack.emplace_back(cmd); ++m_stackIdx; + cmd->redo(); } void UndoStack::redo() noexcept { - m_stack[m_stackIdx++]->redo(); + if (m_stackIdx < m_stack.size()) { + m_stack[m_stackIdx++]->redo(); + } } void UndoStack::undo() noexcept { - m_stack[m_stackIdx--]->undo(); + if (m_stackIdx < ox::MaxValue) { + m_stack[m_stackIdx--]->undo(); + } } } \ No newline at end of file