diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-03 12:39:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-03 20:45:19 +0100 |
commit | ca056ed3fa25b417bc88786377999b04640b1265 (patch) | |
tree | 2014c94b25a9ba9be7c270fb80f09531a30d8eb0 /src | |
parent | 0f2c736de46f5f85fc75eb04445913fe3721cbde (diff) |
[new compiler] Fix tst_qqmlvaluetypes
* Make sure to remove earlier set bindings for any value type property, not just
scripts. We want font.bold: false to also override an earlier actual binding
for example.
* Propagate on assignments on qualified property names throughout the
chain of bindings - that makes it easier to detect them early on.
* The group property collection in the bindings validator should only include
value bindings to group properties, not on assignments - as they can always
appear in parallel.
Change-Id: Ib7ec4de755a5a8d269324a77cba36eb945366274
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 7 | ||||
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator_p.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 2 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 87f2651f42..336c3a11bc 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -939,7 +939,7 @@ void QQmlCodeGenerator::appendBinding(QQmlJS::AST::UiQualifiedId *name, int obje { const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken; QmlObject *object = 0; - if (!resolveQualifiedId(&name, &object)) + if (!resolveQualifiedId(&name, &object, isOnAssignment)) return; qSwap(_object, object); appendBinding(qualifiedNameLocation, name->identifierToken, registerString(name->name.toString()), objectIndex, /*isListItem*/false, isOnAssignment); @@ -1058,7 +1058,7 @@ bool QQmlCodeGenerator::setId(const QQmlJS::AST::SourceLocation &idLocation, QQm return true; } -bool QQmlCodeGenerator::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object) +bool QQmlCodeGenerator::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object, bool onAssignment) { QQmlJS::AST::UiQualifiedId *qualifiedIdElement = *nameToResolve; @@ -1105,6 +1105,9 @@ bool QQmlCodeGenerator::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToRe binding->valueLocation.column = qualifiedIdElement->next->identifierToken.startColumn; binding->flags = 0; + if (onAssignment) + binding->flags |= QV4::CompiledData::Binding::IsOnAssignment; + if (isAttachedProperty) binding->type = QV4::CompiledData::Binding::Type_AttachedProperty; else diff --git a/src/qml/compiler/qqmlcodegenerator_p.h b/src/qml/compiler/qqmlcodegenerator_p.h index 61f97a9bd0..fdb68915de 100644 --- a/src/qml/compiler/qqmlcodegenerator_p.h +++ b/src/qml/compiler/qqmlcodegenerator_p.h @@ -378,7 +378,7 @@ public: // resolves qualified name (font.pixelSize for example) and returns the last name along // with the object any right-hand-side of a binding should apply to. - bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object); + bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, QmlObject **object, bool onAssignment = false); void recordError(const QQmlJS::AST::SourceLocation &location, const QString &description); diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 034e576d8b..2a8536a065 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1664,6 +1664,9 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD if (!binding->isGroupProperty()) continue; + if (binding->flags & QV4::CompiledData::Binding::IsOnAssignment) + continue; + if (populatingValueTypeGroupProperty) { recordError(binding->location, tr("Property assignment expected")); return false; @@ -1797,6 +1800,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD if (!bindingToDefaultProperty && !binding->isGroupProperty() + && !(binding->flags & QV4::CompiledData::Binding::IsOnAssignment) && assigningToGroupProperty) { QV4::CompiledData::Location loc = binding->valueLocation; if (loc < (*assignedGroupProperty)->valueLocation) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index e275b92518..e965cab179 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -603,8 +603,6 @@ void QQmlObjectCreator::setupBindings(const QBitArray &bindingsToSkip) const QV4::CompiledData::Binding *binding = _compiledObject->bindingTable(); for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) { - if (binding->type != QV4::CompiledData::Binding::Type_Script) - continue; property = binding->propertyNameIndex != 0 ? _propertyCache->property(stringAt(binding->propertyNameIndex), _qobject, context) : defaultProperty; if (property) bindingSkipList |= (1 << property->coreIndex); |