Fix issue#1241
This commit is contained in:
itsmattkc
2020-10-04 21:39:16 +11:00
committed by GitHub
4 changed files with 18 additions and 6 deletions
+16
View File
@@ -154,6 +154,15 @@ void NodeRemoveCommand::redo_internal()
// Take nodes from graph (TakeNode() will automatically disconnect edges)
foreach (Node* n, nodes_) {
// If the node is a block, unlink any linked blocks before removing
if (n->IsBlock()) {
Block *b = static_cast<Block *>(n);
if (b->HasLinks()) {
BlockUnlinkAllCommand *unlink_command = new BlockUnlinkAllCommand(b);
unlink_command->redo();
block_unlink_commands_.append(unlink_command);
}
}
graph_->TakeNode(n, &memory_manager_);
}
}
@@ -165,12 +174,19 @@ void NodeRemoveCommand::undo_internal()
graph_->AddNode(n);
}
// Relink any blocks that were unlinked
foreach(BlockUnlinkAllCommand* command, block_unlink_commands_) {
command->undo();
delete command;
}
// Re-connect edges
foreach (NodeEdgePtr edge, edges_) {
NodeParam::ConnectEdge(edge->output(), edge->input());
}
edges_.clear();
block_unlink_commands_.clear();
}
Project *NodeRemoveCommand::GetRelevantProject() const
+2
View File
@@ -27,6 +27,7 @@
#include "node/node.h"
#include "nodeviewitem.h"
#include "undo/undocommand.h"
#include "widget/timelinewidget/undo/undo.h"
OLIVE_NAMESPACE_ENTER
@@ -112,6 +113,7 @@ private:
NodeGraph* graph_;
QList<Node*> nodes_;
QList<NodeEdgePtr> edges_;
QList<BlockUnlinkAllCommand*> block_unlink_commands_;
};
class NodeRemoveWithExclusiveDeps : public UndoCommand {
@@ -494,8 +494,6 @@ void TimelineWidget::ReplaceBlocksWithGaps(const QList<Block *> &blocks,
new TrackReplaceBlockWithGapCommand(original_track, b, command);
if (remove_from_graph) {
new BlockUnlinkAllCommand(b, command);
new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(b->parent()), b, command);
}
}
-4
View File
@@ -243,10 +243,6 @@ void TrackRippleRemoveAreaCommand::redo_internal()
foreach (Block* remove_block, removed_blocks_) {
track_->RippleRemoveBlock(remove_block);
BlockUnlinkAllCommand* unlink_command = new BlockUnlinkAllCommand(remove_block);
unlink_command->redo();
remove_block_commands_.append(unlink_command);
NodeRemoveWithExclusiveDeps* remove_command = new NodeRemoveWithExclusiveDeps(static_cast<NodeGraph*>(remove_block->parent()), remove_block);
remove_command->redo();
remove_block_commands_.append(remove_command);