diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-04 15:46:48 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-05 19:48:26 +0100 |
commit | 37019a96db01b99a76b67b9e655bc457e8edb5a1 (patch) | |
tree | a8979cda9124b77ad28211750612e2b31f4ad344 /src/qml | |
parent | 1845ae01929cdaf6aa50ae096fe5c249f14b1f18 (diff) |
[new compiler] Fix propagation of imported scripts for anonymous components
We must take the imported scripts from the creation context. Fixes various
errors in Qt Quick Controls.
Change-Id: I336d8ffa0537cefd4eeac15f98bbf1b0a5c784af
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 3 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 2 |
4 files changed, 10 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 898a00a9bb..bf87a9dd2d 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -862,7 +862,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) enginePriv->referenceScarceResources(); QObject *rv = 0; if (enginePriv->useNewCompiler) { - state.creator = new QmlObjectCreator(context, cc); + state.creator = new QmlObjectCreator(context, cc, creationContext); rv = state.creator->create(start); if (!rv) state.errors = state.creator->errors; @@ -1057,7 +1057,7 @@ void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, p->compiledData = d->cc; p->compiledData->addref(); if (enginePriv->useNewCompiler) { - p->creator.reset(new QmlObjectCreator(contextData, d->cc)); + p->creator.reset(new QmlObjectCreator(contextData, d->cc, d->creationContext)); p->subComponentToCreate = d->start; } else p->vme.init(contextData, d->cc, d->start, d->creationContext); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index e2f1212e84..933242ba72 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -80,13 +80,14 @@ static void removeBindingOnProperty(QObject *o, int index) if (binding) binding->destroy(); } -QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlContextData *rootContext) +QmlObjectCreator::QmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlContextData *creationContext, QQmlContextData *rootContext) : componentAttached(0) , url(compiledData->url) , engine(parentContext->engine) , qmlUnit(compiledData->qmlUnit) , jsUnit(compiledData->compilationUnit) , parentContext(parentContext) + , creationContext(creationContext) , context(0) , resolvedTypes(compiledData->resolvedTypes) , propertyCaches(compiledData->propertyCaches) @@ -153,8 +154,8 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent) QQmlScriptData *s = compiledData->scripts.at(i); scripts->putIndexed(i, s->scriptValueForContext(context)); } - } else if (parentContext) { - context->importedScripts = parentContext->importedScripts; + } else if (creationContext) { + context->importedScripts = creationContext->importedScripts; } QVector<QQmlParserStatus*> parserStatusCallbacks; @@ -942,7 +943,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, rootContext); + QmlObjectCreator subCreator(context, typeRef->component, creationContext, rootContext); instance = subCreator.create(); if (!instance) { errors += subCreator.errors; diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 424d2e55cd..e5fe4e3b81 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -57,7 +57,7 @@ class QmlObjectCreator { Q_DECLARE_TR_FUNCTIONS(QmlObjectCreator) public: - QmlObjectCreator(QQmlContextData *contextData, QQmlCompiledData *compiledData, QQmlContextData *rootContext = 0); + QmlObjectCreator(QQmlContextData *contextData, QQmlCompiledData *compiledData, QQmlContextData *creationContext, QQmlContextData *rootContext = 0); QObject *create(int subComponentIndex = -1, QObject *parent = 0); QQmlContextData *finalize(); @@ -85,6 +85,7 @@ private: const QV4::CompiledData::QmlUnit *qmlUnit; const QV4::CompiledData::CompilationUnit *jsUnit; QQmlContextData *parentContext; + QQmlContextData *creationContext; QQmlContextData *context; const QHash<int, QQmlCompiledData::TypeReference*> resolvedTypes; const QVector<QQmlPropertyCache *> propertyCaches; diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 5dbccefbde..5f0d26725c 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1873,7 +1873,7 @@ void QQmlDelegateModelItem::incubateObject( incubatorPriv->compiledData = componentPriv->cc; incubatorPriv->compiledData->addref(); if (enginePriv->useNewCompiler) { - incubatorPriv->creator.reset(new QmlObjectCreator(context, componentPriv->cc)); + incubatorPriv->creator.reset(new QmlObjectCreator(context, componentPriv->cc, componentPriv->creationContext)); incubatorPriv->subComponentToCreate = componentPriv->start; } else { incubatorPriv->vme.init( |