[new compiler] Fix tst_qqmlvaluetypes
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 3 Mar 2014 11:39:32 +0000 (12:39 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 3 Mar 2014 19:45:19 +0000 (20:45 +0100)
* 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>
src/qml/compiler/qqmlcodegenerator.cpp
src/qml/compiler/qqmlcodegenerator_p.h
src/qml/compiler/qqmltypecompiler.cpp
src/qml/qml/qqmlobjectcreator.cpp

index 87f2651f42c688a0e73db991847642c42fd0b8b5..336c3a11bc7ba2368950c1cd2bc72f499721fdd5 100644 (file)
@@ -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
index 61f97a9bd0d3f285049f542f0c05c976fe51a3f4..fdb68915de29098fe642788b8fc1529e8a2ccb81 100644 (file)
@@ -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);
 
index 034e576d8b5ccd88810012aa9030447a88fc5f2c..2a8536a06566551a27edf33512e6e89ab1c7733e 100644 (file)
@@ -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)
index e275b92518f1c8716d716ba8995ae8f6cce17d1f..e965cab179f9bb1a02f814a8d5ad02ad5f9baa41 100644 (file)
@@ -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);