From 7fe8dbc77a40a2f4c9538e6c8cf83405e56fe7e8 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 22 Jul 2021 01:09:06 -0700 Subject: [PATCH] timeline: fixed double remove on transitions Fixes #1655 --- app/widget/timelinewidget/timelinewidget.cpp | 5 +++-- app/widget/timelinewidget/timelinewidget.h | 2 +- app/widget/timelinewidget/tool/pointer.cpp | 2 +- app/widget/timelinewidget/undo/timelineundogeneral.cpp | 2 +- app/widget/timelinewidget/undo/timelineundogeneral.h | 5 ++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index 3a0742f45..1d3fbea4a 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -447,7 +447,8 @@ void TimelineWidget::SplitAtPlayhead() void TimelineWidget::ReplaceBlocksWithGaps(const QVector &blocks, bool remove_from_graph, - MultiUndoCommand *command) + MultiUndoCommand *command, + bool handle_transitions) { foreach (Block* b, blocks) { if (dynamic_cast(b)) { @@ -458,7 +459,7 @@ void TimelineWidget::ReplaceBlocksWithGaps(const QVector &blocks, Track* original_track = b->track(); - command->add_child(new TrackReplaceBlockWithGapCommand(original_track, b)); + command->add_child(new TrackReplaceBlockWithGapCommand(original_track, b, handle_transitions)); if (remove_from_graph) { command->add_child(new NodeRemoveWithExclusiveDependenciesAndDisconnect(b)); diff --git a/app/widget/timelinewidget/timelinewidget.h b/app/widget/timelinewidget/timelinewidget.h index 23853d90f..502243266 100644 --- a/app/widget/timelinewidget/timelinewidget.h +++ b/app/widget/timelinewidget/timelinewidget.h @@ -112,7 +112,7 @@ public: void RestoreSplitterState(const QByteArray& state); - static void ReplaceBlocksWithGaps(const QVector &blocks, bool remove_from_graph, MultiUndoCommand *command); + static void ReplaceBlocksWithGaps(const QVector &blocks, bool remove_from_graph, MultiUndoCommand *command, bool handle_transitions = true); /** * @brief Retrieve the QGraphicsItem at a particular scene position diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index dade2c454..14cc30169 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -591,7 +591,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) blocks_to_delete[i] = blocks_moving.at(i).block; } - parent()->ReplaceBlocksWithGaps(blocks_to_delete, false, command); + parent()->ReplaceBlocksWithGaps(blocks_to_delete, false, command, false); } if (inserting) { diff --git a/app/widget/timelinewidget/undo/timelineundogeneral.cpp b/app/widget/timelinewidget/undo/timelineundogeneral.cpp index e9b2cda64..a44099fa6 100644 --- a/app/widget/timelinewidget/undo/timelineundogeneral.cpp +++ b/app/widget/timelinewidget/undo/timelineundogeneral.cpp @@ -441,7 +441,7 @@ void TrackListInsertGaps::undo() void TrackReplaceBlockWithGapCommand::redo() { // Determine if this block is connected to any transitions that should also be removed by this operation - if (transition_remove_commands_.isEmpty()) { + if (handle_transitions_ && transition_remove_commands_.isEmpty()) { CreateRemoveTransitionCommandIfNecessary(false); CreateRemoveTransitionCommandIfNecessary(true); } diff --git a/app/widget/timelinewidget/undo/timelineundogeneral.h b/app/widget/timelinewidget/undo/timelineundogeneral.h index b47587ff5..fe07ed764 100644 --- a/app/widget/timelinewidget/undo/timelineundogeneral.h +++ b/app/widget/timelinewidget/undo/timelineundogeneral.h @@ -196,12 +196,13 @@ private: class TrackReplaceBlockWithGapCommand : public UndoCommand { public: - TrackReplaceBlockWithGapCommand(Track* track, Block* block) : + TrackReplaceBlockWithGapCommand(Track* track, Block* block, bool handle_transitions = true) : track_(track), block_(block), existing_gap_(nullptr), existing_merged_gap_(nullptr), our_gap_(nullptr), + handle_transitions_(handle_transitions), position_command_(nullptr) { } @@ -232,6 +233,8 @@ private: bool existing_gap_precedes_; GapBlock* our_gap_; + bool handle_transitions_; + NodeSetPositionAsChildCommand* position_command_; QObject memory_manager_;