forked from qt-creator/qt-creator
QmlDesigner: Notify tools before deleting FormEditorItems
Calling itemsAboutToRemoved() prior to deleting FormEditorItems ensures selection-related tools don’t access freed pointers during an undo operation. Found in https://the-qt-company-00.sentry.io/issues/6416987849 Pick-to: qds/4.7 Change-Id: I94dc1e93b380c2dc22120dbe43568815f0c484ed Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -194,23 +194,21 @@ void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode)
|
|||||||
QList<FormEditorItem *> removedItemList;
|
QList<FormEditorItem *> removedItemList;
|
||||||
|
|
||||||
if (qmlItemNode.isValid()) {
|
if (qmlItemNode.isValid()) {
|
||||||
QList<QmlItemNode> nodeList;
|
QList<QmlItemNode> nodeList = qmlItemNode.allSubModelNodes();
|
||||||
nodeList.append(qmlItemNode.allSubModelNodes());
|
|
||||||
nodeList.append(qmlItemNode);
|
nodeList.append(qmlItemNode);
|
||||||
|
|
||||||
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
|
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
|
||||||
|
} else if (isFlowNonItem(qmlItemNode)) {
|
||||||
|
removedItemList.append(scene()->itemsForQmlItemNodes({qmlItemNode}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!removedItemList.isEmpty()) {
|
||||||
|
m_currentTool->itemsAboutToRemoved(removedItemList);
|
||||||
|
|
||||||
//The destructor of QGraphicsItem does delete all its children.
|
//The destructor of QGraphicsItem does delete all its children.
|
||||||
//We have to keep the children if they are not children in the model anymore.
|
//We have to keep the children if they are not children in the model anymore.
|
||||||
//Otherwise we delete the children explicitly anyway.
|
//Otherwise we delete the children explicitly anyway.
|
||||||
deleteWithoutChildren(removedItemList);
|
deleteWithoutChildren(removedItemList);
|
||||||
} else if (isFlowNonItem(qmlItemNode)) {
|
|
||||||
removedItemList.append(scene()->itemsForQmlItemNodes({qmlItemNode}));
|
|
||||||
deleteWithoutChildren(removedItemList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removedItemList.isEmpty())
|
|
||||||
m_currentTool->itemsAboutToRemoved(removedItemList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorView::createFormEditorWidget()
|
void FormEditorView::createFormEditorWidget()
|
||||||
|
Reference in New Issue
Block a user