diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-04 10:21:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-04 18:29:04 +0100 |
commit | 50269fc37a6a50864bf08b25327a05f2ab885a1a (patch) | |
tree | e04689e2afc058c404b70dbf0ccc4266df36664a /src/qml/compiler/qqmltypecompiler.cpp | |
parent | 63b8285a2d528be82015133bd72a91c17c3a460b (diff) |
[new compiler] Fix order of alias vs non-alias bindings
qqmlecmascript's alias binding tests expect bindings on non-aliases to be bound
before bindings on aliases, as the latter may override parts of the former.
Change-Id: I23d25c2b7a449f0ed4672ef6865c4a7ef0ed0129
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmltypecompiler.cpp')
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 6197ddf5d0..ea99c51bcf 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -156,6 +156,11 @@ bool QQmlTypeCompiler::compile() return false; } + { + QQmlAliasAnnotator annotator(this); + annotator.annotateBindingsToAliases(); + } + // Collect imported scripts const QList<QQmlTypeData::ScriptReference> &scripts = typeData->resolvedScripts(); compiledData->scripts.reserve(scripts.count()); @@ -963,6 +968,37 @@ int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, const QByteArray &e return -1; } + +QQmlAliasAnnotator::QQmlAliasAnnotator(QQmlTypeCompiler *typeCompiler) + : QQmlCompilePass(typeCompiler) + , qmlObjects(*typeCompiler->qmlObjects()) + , propertyCaches(typeCompiler->propertyCaches()) +{ +} + +void QQmlAliasAnnotator::annotateBindingsToAliases() +{ + for (int i = 0; i < qmlObjects.count(); ++i) { + QQmlPropertyCache *propertyCache = propertyCaches.at(i); + if (!propertyCache) + continue; + + const QmlObject *obj = qmlObjects.at(i); + + PropertyResolver resolver(propertyCache); + QQmlPropertyData *defaultProperty = obj->indexOfDefaultProperty != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty(); + + for (QtQml::Binding *binding = obj->firstBinding(); binding; binding = binding->next) { + if (!binding->isValueBinding()) + continue; + bool notInRevision = false; + QQmlPropertyData *pd = binding->propertyNameIndex != 0 ? resolver.property(stringAt(binding->propertyNameIndex), ¬InRevision) : defaultProperty; + if (pd && pd->isAlias()) + binding->flags |= QV4::CompiledData::Binding::IsBindingToAlias; + } + } +} + QQmlComponentAndAliasResolver::QQmlComponentAndAliasResolver(QQmlTypeCompiler *typeCompiler) : QQmlCompilePass(typeCompiler) , enginePrivate(typeCompiler->enginePrivate()) |