[new compiler] Fix tst_qqmlincubator::deleteContext
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 6 Feb 2014 15:47:29 +0000 (16:47 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 7 Feb 2014 11:44:12 +0000 (12:44 +0100)
Protect against QQmlContext deletion during incubation re-using the existing
QQmlContextGuard.

Change-Id: Ia1c0241029765cc2e00a9b0ffcf484127de20606
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlincubator.cpp
src/qml/qml/qqmlobjectcreator_p.h
src/qml/qml/qqmlvme.cpp
src/qml/qml/qqmlvme_p.h

index de8eab7bd2a1dce3ca983056a945167d458a44de..1cc75387a378071a29ef80b6e768a4b7b01ef792 100644 (file)
@@ -98,7 +98,10 @@ void QQmlEnginePrivate::incubate(QQmlIncubator &i, QQmlContextData *forContext)
         incubatorList.insert(p.data());
         incubatorCount++;
 
-        p->vmeGuard.guard(&p->vme);
+        if (useNewCompiler)
+            p->vmeGuard.guard(p->creator.data());
+        else
+            p->vmeGuard.guard(&p->vme);
         p->changeStatus(QQmlIncubator::Loading);
 
         if (incubationController)
@@ -379,7 +382,10 @@ finishIncubate:
             }
         }
     } else {
-        vmeGuard.guard(&vme);
+        if (enginePriv->useNewCompiler)
+            vmeGuard.guard(creator.data());
+        else
+            vmeGuard.guard(&vme);
     }
 }
 
index 7ed75670c262b602933e112c754bfa74634089b8..251628d5f869dae9d22a9c5c11b3c349310c9618 100644 (file)
@@ -70,6 +70,8 @@ public:
 
     QList<QQmlError> errors;
 
+    QQmlContextData *parentContextData() const { return parentContext; }
+
 private:
     QObject *createInstance(int index, QObject *parent = 0);
 
index 7d521192adacda540d31df864595491de65b787f..7d1e8cc8f0fdbafc33af8cba5b7986064a04f276 100644 (file)
@@ -1307,6 +1307,14 @@ void QQmlVMEGuard::guard(QQmlVME *vme)
         m_contexts[m_contextCount - 1] = vme->rootContext.contextData();
 }
 
+void QQmlVMEGuard::guard(QmlObjectCreator *creator)
+{
+    clear();
+    m_contextCount = 1;
+    m_contexts = new QQmlGuardedContextData[m_contextCount];
+    m_contexts[0] = creator->parentContextData();
+}
+
 void QQmlVMEGuard::clear()
 {
     delete [] m_objects;
index 5025653524c7907bf0a69a7b28da45fbb0e7ae15..4da1aec74bbe7f7d5ba21eebeda18ec4df0ecd4f 100644 (file)
@@ -196,6 +196,7 @@ public:
     ~QQmlVMEGuard();
 
     void guard(QQmlVME *);
+    void guard(QmlObjectCreator *);
     void clear();
 
     bool isOK() const;