nodeparamview: fixed crash
This commit is contained in:
@@ -74,6 +74,7 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) :
|
||||
for (int i=0; i<context_items_.size(); i++) {
|
||||
NodeParamViewContext *c = new NodeParamViewContext;
|
||||
c->setVisible(false);
|
||||
connect(c, &NodeParamViewContext::AboutToDeleteItem, this, &NodeParamView::ItemAboutToBeRemoved, Qt::DirectConnection);
|
||||
|
||||
NodeParamViewItemTitleBar *title_bar = static_cast<NodeParamViewItemTitleBar*>(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<Node *> &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++) {
|
||||
|
||||
@@ -158,6 +158,8 @@ private slots:
|
||||
|
||||
void UpdateContexts();
|
||||
|
||||
void ItemAboutToBeRemoved(NodeParamViewItem *item);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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_) {
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user