diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-05-28 10:09:45 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-28 05:25:06 +0200 |
commit | 508cbc6704ba9a37bd87bcbb5c0f1459bc41c064 (patch) | |
tree | e4bd51a3ab19ac5a73f166a1c393c42a0c139c43 /src | |
parent | 44643036ad1a79e9187406eefcd762489954fa7e (diff) | |
download | qtquick1-508cbc6704ba9a37bd87bcbb5c0f1459bc41c064.tar.gz |
Fix memory leak in qdeclarativevisualdatamodel.
Cherry-pick of b26a588c1702a84ba853df3c757d879cc9f2fc46 from 4.8
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: I4a500b41b02d3cb5dfead4b87ac86e9583024108
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index f49ecc14..ec840f4c 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1057,8 +1057,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); |