Commit 565158bb authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne
Browse files

Always reset the id for an object in node instances

Because we tested for the parent, the id of a root item never reset.
This was hidden because if you remove a root item all
child items was removed too. But if the object was not deleted by the
root item and there was a binding the root item id, there was a dangling
pointer.

Task-Number: BAUHAUS-662
Reviewed-by: kkoehne
parent 628375a5
......@@ -123,13 +123,15 @@ void ObjectNodeInstance::destroy()
{
if (deleteHeldInstance()) {
// Remove from old property
if (object() && modelNode().isValid() && modelNode().parentProperty().isValid()) {
if (object()) {
setId(QString());
NodeAbstractProperty parentProperty = modelNode().parentProperty();
ModelNode parentNode = parentProperty.parentModelNode();
if (parentNode.isValid() && nodeInstanceView()->hasInstanceForNode(parentNode)) {
NodeInstance parentInstance = nodeInstanceView()->instanceForNode(parentNode);
reparent(parentInstance, parentProperty.name(), NodeInstance() , QString());
if (modelNode().isValid() && modelNode().parentProperty().isValid()) {
NodeAbstractProperty parentProperty = modelNode().parentProperty();
ModelNode parentNode = parentProperty.parentModelNode();
if (parentNode.isValid() && nodeInstanceView()->hasInstanceForNode(parentNode)) {
NodeInstance parentInstance = nodeInstanceView()->instanceForNode(parentNode);
reparent(parentInstance, parentProperty.name(), NodeInstance() , QString());
}
}
}
......
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