reworked all timeline commands

I'll be honest, this stuff probably caused a lot of crashes. Objects were constantly created and destroyed without the foresight that other commands might be using them. This should fix a lot of that.
This commit is contained in:
itsmattkc
2021-01-15 14:36:21 +11:00
parent 96c0921193
commit 91740dd823
11 changed files with 1990 additions and 1912 deletions
-1
View File
@@ -22,7 +22,6 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/timelinewidget/timelineandtrackview.cpp
widget/timelinewidget/timelineandtrackview.h
widget/timelinewidget/timelineundo.cpp
widget/timelinewidget/timelineundo.h
widget/timelinewidget/timelinewidget.cpp
widget/timelinewidget/timelinewidget.h
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -4
View File
@@ -469,9 +469,7 @@ void TimelineWidget::DeleteSelected(bool ripple)
// For transitions, remove them but extend their attached blocks to fill their place
foreach (TransitionBlock* transition, transitions_to_delete) {
new TransitionRemoveCommand(transition->track(),
transition,
command);
new TransitionRemoveCommand(transition, command);
Node::RemoveNodesAndExclusiveDependencies(transition, command);
}
@@ -480,7 +478,7 @@ void TimelineWidget::DeleteSelected(bool ripple)
ReplaceBlocksWithGaps(clips_to_delete, true, command);
// Remove all selections
new TimelineSetSelectionsCommand(this, TimelineWidgetSelections(), GetSelections(), command);
new SetSelectionsCommand(this, TimelineWidgetSelections(), GetSelections(), command);
// Insert ripple command now that it's all cleaned up gaps
if (ripple) {
@@ -195,6 +195,34 @@ public:
*/
void SignalDeselectedAllBlocks();
class SetSelectionsCommand : public QUndoCommand {
public:
SetSelectionsCommand(TimelineWidget* timeline, const TimelineWidgetSelections& now, const TimelineWidgetSelections& old, QUndoCommand* parent = nullptr) :
QUndoCommand(parent),
timeline_(timeline),
old_(old),
now_(now)
{
}
protected:
virtual void redo() override
{
timeline_->SetSelections(now_);
}
virtual void undo() override
{
timeline_->SetSelections(old_);
}
private:
TimelineWidget* timeline_;
TimelineWidgetSelections old_;
TimelineWidgetSelections now_;
};
signals:
void BlocksSelected(const QVector<Block*>& selected_blocks);
+3 -3
View File
@@ -590,7 +590,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
} else {
new_sel.TrimOut(reference_ghost->GetOutAdjustment());
}
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
new TimelineWidget::SetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
}
}
@@ -655,7 +655,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
TimelineWidgetSelections new_sel = parent()->GetSelections();
new_sel.ShiftTime(blocks_moving.first().ghost->GetInAdjustment());
new_sel.ShiftTracks(drag_track_type_, blocks_moving.first().ghost->GetTrackAdjustment());
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
new TimelineWidget::SetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
}
if (!blocks_sliding.isEmpty()) {
@@ -717,7 +717,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
// Adjust selections
TimelineWidgetSelections new_sel = parent()->GetSelections();
new_sel.ShiftTime(movement);
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
new TimelineWidget::SetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
}
}
+1 -1
View File
@@ -138,7 +138,7 @@ void RippleTool::FinishDrag(TimelineViewMouseEvent *event)
} else {
new_sel.TrimOut(reference_ghost->GetOutAdjustment());
}
new TimelineSetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
new TimelineWidget::SetSelectionsCommand(parent(), new_sel, parent()->GetSelections(), command);
}
Core::instance()->undo_stack()->pushIfHasChildren(command);