From 05a8a9f25ad84f8330160d98f0ea4b570c3d12fa Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:38:13 -0700 Subject: [PATCH 1/4] graph: use directconnection I don't know, but this might help fix certain crashes where a "connect" signal is received before an "add" signal --- app/node/graph.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/node/graph.cpp b/app/node/graph.cpp index 53fb04e51..a2d04b233 100644 --- a/app/node/graph.cpp +++ b/app/node/graph.cpp @@ -95,10 +95,10 @@ void NodeGraph::childEvent(QChildEvent *event) node_children_.append(node); // Connect signals - connect(node, &Node::InputConnected, this, &NodeGraph::InputConnected); - connect(node, &Node::InputDisconnected, this, &NodeGraph::InputDisconnected); - connect(node, &Node::ValueChanged, this, &NodeGraph::ValueChanged); - connect(node, &Node::InputValueHintChanged, this, &NodeGraph::InputValueHintChanged); + connect(node, &Node::InputConnected, this, &NodeGraph::InputConnected, Qt::DirectConnection); + connect(node, &Node::InputDisconnected, this, &NodeGraph::InputDisconnected, Qt::DirectConnection); + connect(node, &Node::ValueChanged, this, &NodeGraph::ValueChanged, Qt::DirectConnection); + connect(node, &Node::InputValueHintChanged, this, &NodeGraph::InputValueHintChanged, Qt::DirectConnection); emit NodeAdded(node); emit node->AddedToGraph(this); From b3566f94207fdeda315b63e4766c6bfb9b0a2f97 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:47:01 -0700 Subject: [PATCH 2/4] nodes: use more directconnections Still don't know if this will help, but I guess we'll see --- app/render/previewautocacher.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/render/previewautocacher.cpp b/app/render/previewautocacher.cpp index d18975da7..0643628e5 100644 --- a/app/render/previewautocacher.cpp +++ b/app/render/previewautocacher.cpp @@ -854,12 +854,12 @@ void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node) UpdateLastSyncedValue(); // Connect signals for future node additions/deletions - connect(graph, &NodeGraph::NodeAdded, this, &PreviewAutoCacher::NodeAdded); - connect(graph, &NodeGraph::NodeRemoved, this, &PreviewAutoCacher::NodeRemoved); - connect(graph, &NodeGraph::InputConnected, this, &PreviewAutoCacher::EdgeAdded); - connect(graph, &NodeGraph::InputDisconnected, this, &PreviewAutoCacher::EdgeRemoved); - connect(graph, &NodeGraph::ValueChanged, this, &PreviewAutoCacher::ValueChanged); - connect(graph, &NodeGraph::InputValueHintChanged, this, &PreviewAutoCacher::ValueHintChanged); + connect(graph, &NodeGraph::NodeAdded, this, &PreviewAutoCacher::NodeAdded, Qt::DirectConnection); + connect(graph, &NodeGraph::NodeRemoved, this, &PreviewAutoCacher::NodeRemoved, Qt::DirectConnection); + connect(graph, &NodeGraph::InputConnected, this, &PreviewAutoCacher::EdgeAdded, Qt::DirectConnection); + connect(graph, &NodeGraph::InputDisconnected, this, &PreviewAutoCacher::EdgeRemoved, Qt::DirectConnection); + connect(graph, &NodeGraph::ValueChanged, this, &PreviewAutoCacher::ValueChanged, Qt::DirectConnection); + connect(graph, &NodeGraph::InputValueHintChanged, this, &PreviewAutoCacher::ValueHintChanged, Qt::DirectConnection); connect(viewer_node_, &ViewerOutput::VideoAutoCacheChanged, From 407407491f30eae5e917ec6cf711d5d6c6cfb75d Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:05:35 -0700 Subject: [PATCH 3/4] timeline: add null check --- app/widget/timelinewidget/tool/pointer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/widget/timelinewidget/tool/pointer.cpp b/app/widget/timelinewidget/tool/pointer.cpp index 3ae226ee0..1ea1ba703 100644 --- a/app/widget/timelinewidget/tool/pointer.cpp +++ b/app/widget/timelinewidget/tool/pointer.cpp @@ -721,10 +721,13 @@ void PointerTool::InitiateDrag(Block *clicked_item, TimelineViewGhostItem* PointerTool::AddGhostFromBlock(Block* block, Timeline::MovementMode mode, bool check_if_exists) { - if (!block) { + // Ignore null blocks or blocks that aren't attached to a track because there's nothing we can + // do with either of those + if (!block || !block->track()) { return nullptr; } + // Check if we've already made a ghost for this block if (check_if_exists) { foreach (TimelineViewGhostItem* ghost, parent()->GetGhostItems()) { if (Node::ValueToPtr(ghost->GetData(TimelineViewGhostItem::kAttachedBlock)) == block) { @@ -733,6 +736,7 @@ TimelineViewGhostItem* PointerTool::AddGhostFromBlock(Block* block, Timeline::Mo } } + // Otherwise, it's time to make a ghost for this block TimelineViewGhostItem* ghost = TimelineViewGhostItem::FromBlock(block); #ifdef HIDE_GAP_GHOSTS From c7bcf4ecad8f8cc492c4f9c2040c67f77c5f03db Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:10:31 -0700 Subject: [PATCH 4/4] nodeview: remove from attached items when removing node --- app/widget/nodeview/nodeview.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index c4155ab8e..2f72419fd 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -980,6 +980,13 @@ void NodeView::OpenSelectedNodeInViewer() void NodeView::RemoveNode(Node *node) { + for (auto it=attached_items_.begin(); it!=attached_items_.end(); ) { + if (it->item->GetNode() == node) { + it = attached_items_.erase(it); + } else { + it++; + } + } for (const Node::OutputConnection &oc : node->output_connections()) { scene_.RemoveEdge(oc.first, oc.second); }