Fix assert for m_objectInstanceHash

The hash was not cleaned up in any case and sometimes a new object
gets allocated at the exact same address.
To avoid leaking hashes in m_objectInstanceHash and to avoid the assert,
we remove any deleted QObject from the hash.

Change-Id: I2697ab2b2430ad47932841fb9c0ef88ffa4cbbb1
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
Thomas Hartmann
2015-02-23 11:28:23 +01:00
committed by Thomas Hartmann
parent 54ce123a26
commit a2aaf0f6eb
3 changed files with 20 additions and 0 deletions
@@ -111,7 +111,15 @@ ObjectNodeInstance::ObjectNodeInstance(QObject *object)
m_deleteHeldInstance(true),
m_isInLayoutable(false)
{
if (object)
QObject::connect(m_object.data(), &QObject::destroyed, [=] {
/*This lambda is save because m_nodeInstanceServer
is a smartpointer and object is a dangling pointer anyway.*/
if (m_nodeInstanceServer)
m_nodeInstanceServer->removeInstanceRelationsipForDeletedObject(object);
});
}
ObjectNodeInstance::~ObjectNodeInstance()