Fix incorrect ref count with dynamic roles on worker thread.
authorGlenn Watson <glenn.watson@nokia.com>
Sun, 5 Feb 2012 22:44:18 +0000 (08:44 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 6 Feb 2012 03:10:32 +0000 (04:10 +0100)
When using the dynamic roles mode from a worker script thread,
the reference count for the list model worker agent was not
being incremented correctly, causing the final release of the
agent to be reading from memory that had already been freed.

Change-Id: I06d8e363c95133c1c162f32e1efb2d4020ed96be
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/declarative/qml/qdeclarativelistmodel.cpp

index 65b3de9..ce7235e 100644 (file)
@@ -1522,6 +1522,9 @@ QDeclarativeListModel *QDeclarativeListModel::createWithOwner(QDeclarativeListMo
     model->m_agent = newOwner->m_agent;
     model->m_dynamicRoles = newOwner->m_dynamicRoles;
 
+    if (model->m_mainThread && model->m_agent)
+        model->m_agent->addref();
+
     QDeclarativeEngine::setContextForObject(model, QDeclarativeEngine::contextForObject(newOwner));
 
     return model;