[new compiler] Fix component attachment linking across sub object creators
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>
Fri, 7 Feb 2014 11:44:14 +0000 (12:44 +0100)
This brings up the list view in the components gallery.

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

index cc7ea576024153bc5fa17b77734369ba81c9325c..6abf805a4af498b66d412d9216ed381ff49051f1 100644 (file)
@@ -992,7 +992,7 @@ QQmlComponentAttached *QQmlComponent::qmlAttachedProperties(QObject *obj)
     if (p->activeVME) { // XXX should only be allowed during begin
         a->add(&p->activeVME->componentAttached);
     } else if (p->activeObjectCreator) {
-        a->add(&p->activeObjectCreator->componentAttached);
+        a->add(p->activeObjectCreator->componentAttached);
     } else {
         QQmlData *d = QQmlData::get(obj);
         Q_ASSERT(d);
index faeb3753eadde25aac9a03a3cd1f9a838ea0eb25..e2063a979fc6f5ca1732c665eb0c03a0fc8fbd4a 100644 (file)
@@ -110,6 +110,9 @@ QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledD
     if (!compiledData->isInitialized())
         compiledData->initialize(engine);
 
+    componentAttachedImpl = 0;
+    componentAttached = &componentAttachedImpl;
+
     if (inheritedBindingStack) {
         Q_ASSERT(rootContext);
         Q_ASSERT(inheritedParserStatusStack);
@@ -974,13 +977,12 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
                 return 0;
             }
             QmlObjectCreator subCreator(context, typeRef->component, creationContext, rootContext, allCreatedBindings, allParserStatusCallbacks);
+            subCreator.componentAttached = componentAttached;
             instance = subCreator.create();
             if (!instance) {
                 errors += subCreator.errors;
                 return 0;
             }
-            if (subCreator.componentAttached)
-                subCreator.componentAttached->add(&componentAttached);
         }
         // ### use no-event variant
         if (parent)
@@ -1100,8 +1102,8 @@ QQmlContextData *QmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrup
 
     {
     QQmlTrace trace("VME Component.onCompleted Callbacks");
-    while (componentAttached) {
-        QQmlComponentAttached *a = componentAttached;
+    while (componentAttachedImpl) {
+        QQmlComponentAttached *a = componentAttachedImpl;
         a->rem();
         QQmlData *d = QQmlData::get(a->parent());
         Q_ASSERT(d);
index 251628d5f869dae9d22a9c5c11b3c349310c9618..68f2eaeab3a189b63d429a6078adfae814a4e7c8 100644 (file)
@@ -65,7 +65,7 @@ public:
     QObject *create(int subComponentIndex = -1, QObject *parent = 0);
     QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt);
 
-    QQmlComponentAttached *componentAttached;
+    QQmlComponentAttached **componentAttached;
     QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks;
 
     QList<QQmlError> errors;
@@ -101,6 +101,7 @@ private:
     bool ownBindingAndParserStatusStacks;
     QQmlCompiledData *compiledData;
     QQmlContextData *rootContext;
+    QQmlComponentAttached *componentAttachedImpl;
 
     QObject *_qobject;
     QObject *_scopeObject;