Commit dd14b75f authored by Marco Bubke's avatar Marco Bubke
Browse files

Change id removing

parent 355d5a32
......@@ -106,27 +106,30 @@ static void specialRemoveParentForQmlGraphicsItemChildren(QObject *object)
void ObjectNodeInstance::destroy()
{
// Remove from old property
if (object() && modelNode().isValid() && modelNode().parentProperty().isValid()) {
NodeAbstractProperty parentProperty = modelNode().parentProperty();
ModelNode parentNode = parentProperty.parentModelNode();
if (parentNode.isValid() && nodeInstanceView()->hasInstanceForNode(parentNode)) {
NodeInstance parentInstance = nodeInstanceView()->instanceForNode(parentNode);
if (parentInstance.isQmlGraphicsItem() && isChildrenProperty(parentProperty.name())) {
specialRemoveParentForQmlGraphicsItemChildren(object());
} else {
removeFromOldProperty(object(), parentInstance.internalObject(), parentProperty.name());
if (deleteHeldInstance()) {
// Remove from old property
if (object() && modelNode().isValid() && modelNode().parentProperty().isValid()) {
NodeAbstractProperty parentProperty = modelNode().parentProperty();
ModelNode parentNode = parentProperty.parentModelNode();
if (parentNode.isValid() && nodeInstanceView()->hasInstanceForNode(parentNode)) {
NodeInstance parentInstance = nodeInstanceView()->instanceForNode(parentNode);
if (parentInstance.isQmlGraphicsItem() && isChildrenProperty(parentProperty.name())) {
specialRemoveParentForQmlGraphicsItemChildren(object());
} else {
removeFromOldProperty(object(), parentInstance.internalObject(), parentProperty.name());
}
}
}
}
if (deleteHeldInstance() && object()) {
if (!object()->objectName().isEmpty()) {
context()->engine()->rootContext()->setContextProperty(object()->objectName(), 0);
if (!m_id.isEmpty()) {
context()->engine()->rootContext()->setContextProperty(m_id, 0);
}
if (object()) {
QObject *obj = object();
m_object.clear();
delete obj;
}
QObject *obj = object();
m_object.clear();
delete obj;
}
}
......@@ -152,15 +155,15 @@ void ObjectNodeInstance::setNodeInstance(NodeInstanceView *view)
void ObjectNodeInstance::setId(const QString &id)
{
if (!object()->objectName().isEmpty()) {
context()->engine()->rootContext()->setContextProperty(object()->objectName(), 0);
if (!m_id.isEmpty()) {
context()->engine()->rootContext()->setContextProperty(m_id, 0);
}
if (!id.isEmpty()) {
context()->engine()->rootContext()->setContextProperty(id, object()); // will also force refresh of all bindings
}
object()->setObjectName(id);
m_id = id;
}
bool ObjectNodeInstance::isQmlGraphicsItem() const
......
......@@ -174,6 +174,7 @@ private:
QHash<QString, QVariant> m_resetValueHash;
QHash<QString, NodeInstance> m_modelAbstractPropertyHash;
ModelNode m_modelNode;
QString m_id;
QWeakPointer<NodeInstanceView> m_nodeInstanceView;
bool m_deleteHeldInstance;
......
Supports Markdown
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