From 1793c7837cc1eab9233892786653054bfbfd8c67 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 18 Sep 2018 21:06:56 +1000 Subject: [PATCH] fixed issue with undo overhaul --- project/undo.cpp | 23 +++++++++++++++++++++++ project/undo.h | 3 +++ ui/keyframeview.cpp | 2 -- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/project/undo.cpp b/project/undo.cpp index dc488d5ca..b3d42827a 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -81,13 +81,36 @@ DeleteClipAction::~DeleteClipAction() { } void DeleteClipAction::undo() { + // restore ref to clip seq->clips[index] = ref; ref = NULL; + + // restore links to this clip + for (int i=linkClipIndex.size()-1;i>=0;i--) { + seq->clips.at(linkClipIndex.at(i))->linked.insert(linkLinkIndex.at(i), index); + } } void DeleteClipAction::redo() { + // remove ref to clip ref = seq->clips.at(index); seq->clips[index] = NULL; + + // delete link to this clip + linkClipIndex.clear(); + linkLinkIndex.clear(); + for (int i=0;iclips.size();i++) { + Clip* c = seq->clips.at(i); + if (c != NULL) { + for (int j=0;jlinked.size();j++) { + if (c->linked.at(j) == index) { + linkClipIndex.append(i); + linkLinkIndex.append(j); + c->linked.removeAt(j); + } + } + } + } } ChangeSequenceAction::ChangeSequenceAction(Sequence* s) : diff --git a/project/undo.h b/project/undo.h index da882def9..539c6a1d2 100644 --- a/project/undo.h +++ b/project/undo.h @@ -62,6 +62,9 @@ private: Sequence* seq; Clip* ref; int index; + + QVector linkClipIndex; + QVector linkLinkIndex; }; class ChangeSequenceAction : public QUndoCommand { diff --git a/ui/keyframeview.cpp b/ui/keyframeview.cpp index 209b03e73..3d0b4e25c 100644 --- a/ui/keyframeview.cpp +++ b/ui/keyframeview.cpp @@ -33,8 +33,6 @@ void KeyframeView::paintEvent(QPaintEvent*) { rowY.clear(); rows.clear(); - - if (panel_effect_controls->selected_clips.size() > 0) { long effects_in = LONG_MAX; long effects_out = 0;