diff --git a/app/widget/nodeparamview/nodeparamview.cpp b/app/widget/nodeparamview/nodeparamview.cpp index 6f2147247..251e37074 100644 --- a/app/widget/nodeparamview/nodeparamview.cpp +++ b/app/widget/nodeparamview/nodeparamview.cpp @@ -74,6 +74,7 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) : for (int i=0; isetVisible(false); + connect(c, &NodeParamViewContext::AboutToDeleteItem, this, &NodeParamView::ItemAboutToBeRemoved, Qt::DirectConnection); NodeParamViewItemTitleBar *title_bar = static_cast(c->titleBarWidget()); @@ -285,6 +286,14 @@ void NodeParamView::UpdateContexts() } } +void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item) +{ + if (focused_node_ == item) { + focused_node_ = nullptr; + emit FocusedNodeChanged(nullptr); + } +} + void NodeParamView::SetContexts(const QVector &contexts) { // Setting contexts is expensive, so we queue it here to prevent multiple calls in a short timespan @@ -458,11 +467,6 @@ void NodeParamView::RemoveNode(Node *n, Node *ctx) NodeParamViewItem *item = ctx_item->GetItem(n, ctx); if (item) { - if (focused_node_ == item) { - focused_node_ = nullptr; - emit FocusedNodeChanged(nullptr); - } - if (keyframe_view_) { for (auto it=item->GetKeyframeConnections().begin(); it!=item->GetKeyframeConnections().end(); it++) { for (auto jt=it->begin(); jt!=it->end(); jt++) { diff --git a/app/widget/nodeparamview/nodeparamview.h b/app/widget/nodeparamview/nodeparamview.h index eeca7e668..bbb5603c4 100644 --- a/app/widget/nodeparamview/nodeparamview.h +++ b/app/widget/nodeparamview/nodeparamview.h @@ -158,6 +158,8 @@ private slots: void UpdateContexts(); + void ItemAboutToBeRemoved(NodeParamViewItem *item); + }; } diff --git a/app/widget/nodeparamview/nodeparamviewcontext.cpp b/app/widget/nodeparamview/nodeparamviewcontext.cpp index a73d41ce2..a07c3975b 100644 --- a/app/widget/nodeparamview/nodeparamviewcontext.cpp +++ b/app/widget/nodeparamview/nodeparamviewcontext.cpp @@ -70,6 +70,7 @@ void NodeParamViewContext::RemoveNode(Node *node, Node *ctx) NodeParamViewItem *item = *it; if (item->GetNode() == node && item->GetContext() == ctx) { + emit AboutToDeleteItem(item); delete item; it = items_.erase(it); } else { @@ -84,6 +85,7 @@ void NodeParamViewContext::RemoveNodesWithContext(Node *ctx) NodeParamViewItem *item = *it; if (item->GetContext() == ctx) { + emit AboutToDeleteItem(item); delete item; it = items_.erase(it); } else { @@ -92,14 +94,6 @@ void NodeParamViewContext::RemoveNodesWithContext(Node *ctx) } } -void NodeParamViewContext::Clear() -{ - qDeleteAll(items_); - items_.clear(); - - contexts_.clear(); -} - void NodeParamViewContext::SetInputChecked(const NodeInput &input, bool e) { foreach (NodeParamViewItem *item, items_) { diff --git a/app/widget/nodeparamview/nodeparamviewcontext.h b/app/widget/nodeparamview/nodeparamviewcontext.h index 3760ea911..5652277e9 100644 --- a/app/widget/nodeparamview/nodeparamviewcontext.h +++ b/app/widget/nodeparamview/nodeparamviewcontext.h @@ -56,8 +56,6 @@ public: void RemoveNodesWithContext(Node *ctx); - void Clear(); - void SetInputChecked(const NodeInput &input, bool e); void SetTimebase(const rational &timebase); @@ -66,6 +64,9 @@ public: void SetTime(const rational &time); +signals: + void AboutToDeleteItem(NodeParamViewItem *item); + public slots: void AddContext(Node *node) {