From 91f2453d119569c803185f38387e434ec2abed87 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 15 Aug 2016 17:11:12 +0100 Subject: [PATCH] Fixed a bug in UndoManager when using undoCurrentTransactionOnly --- .../undomanager/juce_UndoManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp index e552bb8630..819d55a108 100644 --- a/modules/juce_data_structures/undomanager/juce_UndoManager.cpp +++ b/modules/juce_data_structures/undomanager/juce_UndoManager.cpp @@ -171,15 +171,20 @@ void UndoManager::moveFutureTransactionsToStash() while (nextIndex < transactions.size()) { - totalUnitsStored -= transactions.getLast()->getTotalSize(); - stashedFutureTransactions.add (transactions.removeAndReturn (nextIndex)); + ActionSet* removed = transactions.removeAndReturn (nextIndex); + stashedFutureTransactions.add (removed); + totalUnitsStored -= removed->getTotalSize(); } } } void UndoManager::restoreStashedFutureTransactions() { - jassert (nextIndex == transactions.size()); + while (nextIndex < transactions.size()) + { + totalUnitsStored -= transactions.getUnchecked (nextIndex)->getTotalSize(); + transactions.remove (nextIndex); + } for (int i = 0; i < stashedFutureTransactions.size(); ++i) {