nodeview: use null check

In a perfect world, this would be unnecessary, but it will just save us so many crashes to do it.
This commit is contained in:
itsmattkc
2021-05-28 17:58:42 +10:00
parent e2bbff5078
commit 8ef140dcd0
+16 -6
View File
@@ -263,6 +263,8 @@ void NodeView::Select(QVector<Node *> nodes)
// Remove any duplicates
QVector<Node*> processed;
NodeViewItem *first_item = nullptr;
foreach (Node* n, nodes) {
if (processed.contains(n)) {
continue;
@@ -272,17 +274,25 @@ void NodeView::Select(QVector<Node *> nodes)
NodeViewItem* item = scene_.NodeToUIObject(n);
item->setSelected(true);
if (item) {
item->setSelected(true);
if (deselections.contains(n)) {
deselections.removeOne(n);
} else {
new_selections.append(n);
if (!first_item) {
first_item = item;
}
if (deselections.contains(n)) {
deselections.removeOne(n);
} else {
new_selections.append(n);
}
}
}
// Center on something
centerOn(scene_.NodeToUIObject(nodes.first()));
if (first_item) {
centerOn(first_item);
}
ConnectSelectionChangedSignal();