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 <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2021-10-05 18:16:27 +02:00
committed by Thomas Hartmann
parent 033d2c5cc3
commit cfc732fe8f

View File

@@ -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. Deletes this object's node and its dependencies from the model.
Everything that belongs to this Object, the ModelNode, and ChangeOperations Everything that belongs to this Object, the ModelNode, and ChangeOperations
@@ -406,7 +414,7 @@ void QmlObjectNode::destroy()
} }
removeStateOperationsForChildren(modelNode()); removeStateOperationsForChildren(modelNode());
BindingProperty::deleteAllReferencesTo(modelNode()); deleteAllReferencesToNodeAndChildren(modelNode());
QmlFlowViewNode root(view()->rootModelNode()); QmlFlowViewNode root(view()->rootModelNode());