diff --git a/timeline/track.cpp b/timeline/track.cpp index 8d74b9999..37cbc7a91 100644 --- a/timeline/track.cpp +++ b/timeline/track.cpp @@ -195,6 +195,17 @@ Clip *Track::GetClipFromPoint(long point) return nullptr; } +bool Track::ContainsClip(Clip *c) +{ + ClipPtr clip; + foreach (clip, clips_) { + if (clip.get() == c) { + return true; + } + } + return false; +} + Track *Track::Previous() { int index = Index(); diff --git a/timeline/track.h b/timeline/track.h index 23ca28cf4..847f27415 100644 --- a/timeline/track.h +++ b/timeline/track.h @@ -67,6 +67,7 @@ public: QVector GetSelectedClips(bool containing); ClipPtr GetClipObjectFromRawPtr(Clip* c); Clip* GetClipFromPoint(long point); + bool ContainsClip(Clip* c); Track* Previous(); Track* Next(); diff --git a/undo/undo.cpp b/undo/undo.cpp index 1a7ba7e80..82738c21e 100644 --- a/undo/undo.cpp +++ b/undo/undo.cpp @@ -68,7 +68,13 @@ void MoveClipAction::doUndo() { clip->set_timeline_out(old_out); clip->set_clip_in(old_clip_in); } - old_track->AddClip(clip); + + // Move clip to the new track ONLY IF the old track currently contains this clip - a workaround to ensure this + // action doesn't accidentaly add a clip that it's not supposed to + if (new_track->ContainsClip(clip.get())) { + old_track->AddClip(clip); + } + done = false; } @@ -83,7 +89,13 @@ void MoveClipAction::doRedo() { clip->set_timeline_out(new_out); clip->set_clip_in(new_clip_in); } - new_track->AddClip(clip); + + // Move clip to the new track ONLY IF the old track currently contains this clip - a workaround to ensure this + // action doesn't accidentaly add a clip that it's not supposed to + if (old_track->ContainsClip(clip.get())) { + new_track->AddClip(clip); + } + done = true; } }