diff --git a/src/nostalgia/studio/lib/undostack.cpp b/src/nostalgia/studio/lib/undostack.cpp index cbe54356..c8b4b322 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