summaryrefslogtreecommitdiff
path: root/muse2/muse/undo.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-07-03 16:48:36 +0000
committerFlorian Jung <flo@windfisch.org>2011-07-03 16:48:36 +0000
commita0162f23ad2bbb050dcfdf38c80c34f417446159 (patch)
tree8b1064b438d399a7d88b022a7767ad41714d5e17 /muse2/muse/undo.cpp
parente1fbd43836e433c2f19bb5240e19338135b3b2be (diff)
added cleanOperationGroup() function which at least avoids crashes
when processing the same part or track twice in one operation group this however does probably NOT cause intended behaviour. this simply executes the first action with the given pointer and discards the others.
Diffstat (limited to 'muse2/muse/undo.cpp')
-rw-r--r--muse2/muse/undo.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp
index 0c05ef08..d13b38d7 100644
--- a/muse2/muse/undo.cpp
+++ b/muse2/muse/undo.cpp
@@ -15,6 +15,7 @@
#include "globals.h"
#include <QAction>
+#include <set>
// iundo points to last Undo() in Undo-list
@@ -207,10 +208,43 @@ void Song::endUndo(int flags)
}
+void cleanOperationGroup(Undo& group)
+{
+ using std::set;
+
+ set<Track*> processed_tracks;
+ set<Part*> processed_parts;
+
+ for (iUndoOp op=group.begin(); op!=group.end();)
+ {
+ iUndoOp op_=op;
+ op_++;
+
+ if ((op->type==UndoOp::ModifyTrack) || (op->type==UndoOp::DeleteTrack))
+ {
+ if (processed_tracks.find(op->oTrack)!=processed_tracks.end())
+ group.erase(op);
+ else
+ processed_tracks.insert(op->oTrack);
+ }
+ else if ((op->type==UndoOp::ModifyPart) || (op->type==UndoOp::DeletePart))
+ {
+ if (processed_parts.find(op->oPart)!=processed_parts.end())
+ group.erase(op);
+ else
+ processed_parts.insert(op->oPart);
+ }
+
+ op=op_;
+ }
+}
+
+
bool Song::applyOperationGroup(Undo& group, bool doUndo)
{
if (!group.empty())
{
+ cleanOperationGroup(group);
//this is a HACK! but it works :) (added by flo93)
redoList->push_back(group);
redo();