diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 7158cb906..d2bf263bb 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -689,6 +689,8 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) InsertGapsAtGhostDestination(command); } + QMap relinks; + // Now we can re-add each clip foreach (const GhostBlockPair& p, blocks_moving) { Block* block = p.block; @@ -696,7 +698,10 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) if (duplicate_clips) { // Duplicate rather than move // Place the copy instead of the original block - block = static_cast(Node::CopyNodeInGraph(block, command)); + Block *new_block = static_cast(Node::CopyNodeInGraph(block, command)); + relinks.insert(block, new_block); + block = new_block; + if (ClipBlock *new_clip = dynamic_cast(block)) { new_clip->waveform() = static_cast(p.block)->waveform(); } @@ -709,6 +714,18 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event) p.ghost->GetAdjustedIn())); } + if (!relinks.empty()) { + for (auto it=relinks.cbegin(); it!=relinks.cend(); it++) { + for (auto jt=it.key()->links().cbegin(); jt!=it.key()->links().cend(); jt++) { + Node *link = *jt; + Node *copy_link = relinks.value(link); + if (copy_link) { + command->add_child(new NodeLinkCommand(it.value(), copy_link, true)); + } + } + } + } + // Adjust selections TimelineWidgetSelections new_sel = parent()->GetSelections(); new_sel.ShiftTime(blocks_moving.first().ghost->GetInAdjustment());