[new compiler] Fix context ownership for anonymous components
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 6 Feb 2014 20:15:54 +0000 (21:15 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 13 Feb 2014 00:57:56 +0000 (01:57 +0100)
When instantiating an anonymous component, we must also set the context
ownership to true.

Fixes garbage collection of item view delegates, where when the destructor
run, their context wasn't cleared properly and child items would re-evaluate
bindings that use "parent" with null.

Change-Id: I8c67c679c12ce987a0dec405571647270373881c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlobjectcreator.cpp

index e2063a979fc6f5ca1732c665eb0c03a0fc8fbd4a..d7ce9685082708aa4afd0299ab19de5b984eaece 100644 (file)
@@ -991,7 +991,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
 
     QQmlData *ddata = QQmlData::get(instance, /*create*/true);
     ddata->setImplicitDestructible();
-    if (static_cast<quint32>(index) == qmlUnit->indexOfRootObject) {
+    if (static_cast<quint32>(index) == qmlUnit->indexOfRootObject || ddata->rootObjectInCreation) {
         if (ddata->context) {
             Q_ASSERT(ddata->context != context);
             Q_ASSERT(ddata->outerContext);