summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-05-17 07:32:15 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-05-21 05:40:01 (GMT)
commitb26a588c1702a84ba853df3c757d879cc9f2fc46 (patch)
tree4d7b926bdac365daca94c6423cc6ae2af9be9424 /src/declarative/graphicsitems
parent92d7089c57776838b73280e67fe4083fb302aece (diff)
downloadQt-b26a588c1702a84ba853df3c757d879cc9f2fc46.zip
Qt-b26a588c1702a84ba853df3c757d879cc9f2fc46.tar.gz
Qt-b26a588c1702a84ba853df3c757d879cc9f2fc46.tar.bz2
Fix memory leak in qdeclarativevisualdatamodel.
Parent order was backwards, the inner context was parented to the outer context, and then the inner context was reparented to the delegate. Parent the outer context to inner context so both are deleted when the delegate is deleted. Task-number: QTBUG-25784 Change-Id: I1d6cd4dfc2530424535a7e00164563d9b4aaa513 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 3f71e57..42a87b9 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -1056,8 +1056,10 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor
&& d->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) {
- ctxt->setContextObject(d->m_listAccessor->at(index).value<QObject*>());
- ctxt = new QDeclarativeContext(ctxt, ctxt);
+ QDeclarativeContext *objCtxt = ctxt;
+ objCtxt->setContextObject(d->m_listAccessor->at(index).value<QObject*>());
+ ctxt = new QDeclarativeContext(ctxt);
+ QDeclarative_setParent_noEvent(objCtxt, ctxt);
}
ctxt->setContextProperty(QLatin1String("model"), data);
ctxt->setContextObject(data);