aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-03 09:41:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-04 18:28:48 +0100
commit799fff7e59e8c379c069523b305ea29b73f7299d (patch)
treefa566727aeaffd27fcb00c98b8c00669242c67d0 /src/qml/qml/qqmlobjectcreator.cpp
parent5a40ca19d98a76c9ab0c7a9de8f4b31fcdcd9317 (diff)
[new compiler] Set the rootObjectInCreation flag correctly on the root object
Change-Id: Iaf96dabb1b3de81aae75953fd261dfc3b562169c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 2ccacc7793..cbbe54e9de 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -79,7 +79,7 @@ static void removeBindingOnProperty(QObject *o, int index)
if (binding) binding->destroy();
}
-QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData)
+QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlContextData *rootContext)
: componentAttached(0)
, url(compiledData->url)
, engine(parentContext->engine)
@@ -91,7 +91,7 @@ QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledD
, propertyCaches(compiledData->propertyCaches)
, vmeMetaObjectData(compiledData->datas)
, compiledData(compiledData)
- , rootContext(0)
+ , rootContext(rootContext)
, _qobject(0)
, _scopeObject(0)
, _valueTypeProperty(0)
@@ -126,8 +126,10 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->imports->addref();
context->setParent(parentContext);
- if (!rootContext)
+ if (!rootContext) {
rootContext = context;
+ rootContext->isRootObjectInCreation = true;
+ }
QVector<QQmlContextData::ObjectIdMapping> mapping(objectIndexToId.count());
for (QHash<int, int>::ConstIterator it = objectIndexToId.constBegin(), end = objectIndexToId.constEnd();
@@ -879,6 +881,12 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
}
customParser = type->customParser();
+
+ if (rootContext->isRootObjectInCreation) {
+ QQmlData *ddata = QQmlData::get(instance, /*create*/true);
+ ddata->rootObjectInCreation = true;
+ rootContext->isRootObjectInCreation = false;
+ }
} else {
Q_ASSERT(typeRef->component);
if (typeRef->component->qmlUnit->isSingleton())
@@ -886,7 +894,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex)));
return 0;
}
- QmlObjectCreator subCreator(context, typeRef->component);
+ QmlObjectCreator subCreator(context, typeRef->component, rootContext);
instance = subCreator.create();
if (!instance) {
errors += subCreator.errors;