From a0162f23ad2bbb050dcfdf38c80c34f417446159 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 3 Jul 2011 16:48:36 +0000 Subject: 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. --- muse2/muse/undo.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'muse2') 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 +#include // 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 processed_tracks; + set 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(); -- cgit v1.2.3