Commit 6d229ef6 authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann
Browse files

QmlDesigner.NodeInstances: Reset the Id for all child objects before

deletion
parent c7963126
......@@ -111,7 +111,6 @@ public:
private slots:
void emitParentChanged(QObject *child);
void refreshLocalFileProperty(const QString &path);
void removeIdFromContext(QObject *object);
private: // functions
NodeInstance rootNodeInstance() const;
......
......@@ -417,6 +417,11 @@ void NodeInstanceView::removeAllInstanceNodeRelationships()
{
// prevent destroyed() signals calling back
foreach (NodeInstance instance, m_objectInstanceHash.values()) {
if (instance.isValid())
instance.setId(QString());
}
//first the root object
if (rootNodeInstance().internalObject())
rootNodeInstance().internalObject()->disconnect();
......@@ -552,7 +557,8 @@ void NodeInstanceView::removeInstanceNodeRelationship(const ModelNode &node)
{
Q_ASSERT(m_nodeInstanceHash.contains(node));
NodeInstance instance = instanceForNode(node);
removeIdFromContext(instance.internalObject());
if (instance.isValid())
instance.setId(QString());
m_objectInstanceHash.remove(instanceForNode(node).internalObject());
m_nodeInstanceHash.remove(node);
instance.makeInvalid();
......@@ -627,6 +633,10 @@ void NodeInstanceView::activateBaseState()
void NodeInstanceView::removeRecursiveChildRelationship(const ModelNode &removedNode)
{
if (hasInstanceForNode(removedNode)) {
instanceForNode(removedNode).setId(QString());
}
foreach (const ModelNode &childNode, removedNode.allDirectSubModelNodes())
removeRecursiveChildRelationship(childNode);
......@@ -695,16 +705,4 @@ void NodeInstanceView::refreshLocalFileProperty(const QString &path)
}
}
void NodeInstanceView::removeIdFromContext(QObject *object)
{
if (hasInstanceForObject(object)) {
NodeInstance instance = instanceForObject(object);
if (instance.isValid()) {
QString id = instance.id();
if (!id.isEmpty())
engine()->rootContext()->setContextProperty(id, 0);
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment