From 635d999c2c47b781686faeb8f232ff2ece8fbaae Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Sun, 13 Nov 2022 13:16:36 +0800 Subject: [PATCH] Fixed redo not working correctly --- SHADE_Managed/src/Editor/UndoRedoStack.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SHADE_Managed/src/Editor/UndoRedoStack.cxx b/SHADE_Managed/src/Editor/UndoRedoStack.cxx index 789d285d..a83db119 100644 --- a/SHADE_Managed/src/Editor/UndoRedoStack.cxx +++ b/SHADE_Managed/src/Editor/UndoRedoStack.cxx @@ -34,7 +34,8 @@ namespace SHADE bool UndoRedoStack::RedoActionPresent::get() { - return latestActionIndex >= 0 && latestActionIndex < commandStack->Count - 1; + const int REDO_ACTION_INDEX = latestActionIndex + 1; + return REDO_ACTION_INDEX >= 0 && REDO_ACTION_INDEX < commandStack->Count; } /*---------------------------------------------------------------------------------*/ @@ -69,8 +70,9 @@ namespace SHADE { if (!RedoActionPresent) return; - - ICommand^ cmd = commandStack[latestActionIndex]; + + const int REDO_ACTION_INDEX = latestActionIndex + 1; + ICommand^ cmd = commandStack[REDO_ACTION_INDEX]; cmd->Execute(); ++latestActionIndex; }