MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / deleteSelectedNodes

Method deleteSelectedNodes

QtNodeEditor/src/FlowView.cpp:250–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248
249
250void
251FlowView::
252deleteSelectedNodes()
253{
254 // Delete the selected connections first, ensuring that they won't be
255 // automatically deleted when selected nodes are deleted (deleting a node
256 // deletes some connections as well)
257 startNodeDelete();
258
259 for (QGraphicsItem * item : _scene->selectedItems())
260 {
261 if (auto c = qgraphicsitem_cast<ConnectionGraphicsObject*>(item))
262 _scene->deleteConnection(c->connection());
263 }
264
265 // Delete the nodes; this will delete many of the connections.
266 // Selected connections were already deleted prior to this loop, otherwise
267 // qgraphicsitem_cast<NodeGraphicsObject*>(item) could be a use-after-free
268 // when a selected connection is deleted by deleting the node.
269 for (QGraphicsItem * item : _scene->selectedItems())
270 {
271 if (auto n = qgraphicsitem_cast<NodeGraphicsObject*>(item))
272 _scene->removeNode(n->node());
273 }
274
275 finishNodeDelete();
276}
277
278
279void

Callers

nothing calls this directly

Calls 1

nodeMethod · 0.80

Tested by

no test coverage detected