From cfc732fe8f5934da3beba50849d1a378c2efbc47 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 5 Oct 2021 18:16:27 +0200 Subject: [PATCH] QmlDesigner: Remove all references also to children If a node is deleted also children are deleted. We have to remove all references to children, too. Change-Id: Ie944b00ffc832fb0fb11ef0380c4b9b30add5757 Reviewed-by: Miikka Heikkinen --- .../qmldesigner/designercore/model/qmlobjectnode.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp index c5ad9244a25..25f792e9088 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlobjectnode.cpp @@ -368,6 +368,14 @@ static void removeLayerEnabled(const ModelNode &node) } } +static void deleteAllReferencesToNodeAndChildren(const ModelNode &node) +{ + BindingProperty::deleteAllReferencesTo(node); + const auto subNodes = node.allSubModelNodes(); + for (const ModelNode &child : subNodes) + BindingProperty::deleteAllReferencesTo(child); +} + /*! Deletes this object's node and its dependencies from the model. Everything that belongs to this Object, the ModelNode, and ChangeOperations @@ -406,7 +414,7 @@ void QmlObjectNode::destroy() } removeStateOperationsForChildren(modelNode()); - BindingProperty::deleteAllReferencesTo(modelNode()); + deleteAllReferencesToNodeAndChildren(modelNode()); QmlFlowViewNode root(view()->rootModelNode());