Regression: Fix id objects in group properties
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 3 Apr 2014 15:20:18 +0000 (17:20 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 4 Apr 2014 15:26:20 +0000 (17:26 +0200)
Setting someGroupProperty.id should not be subject to the usual
restrictions with regards to valid values for id properties.

Task-number: QTBUG-38085
Change-Id: Ie66d9d4d4524ddaf5a6a0b0e260354db44d9995e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qqmlirbuilder.cpp
tests/auto/qml/qqmllanguage/data/idProperty.qml
tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp

index 1c10a49fd1c483198b0162e0b85dd711b1599ba3..0dac79f6e74a1c83e0908a554fd586738b41b756 100644 (file)
@@ -1275,6 +1275,10 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Sta
     Object *object = 0;
     if (!resolveQualifiedId(&name, &object))
         return;
+    if (_object == object && name->name == QStringLiteral("id")) {
+        setId(name->identifierToken, value);
+        return;
+    }
     qSwap(_object, object);
     appendBinding(qualifiedNameLocation, name->identifierToken, registerString(name->name.toString()), value);
     qSwap(_object, object);
@@ -1293,11 +1297,6 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex,
 
 void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, QQmlJS::AST::Statement *value)
 {
-    if (stringAt(propertyNameIndex) == QStringLiteral("id")) {
-        setId(nameLocation, value);
-        return;
-    }
-
     Binding *binding = New<Binding>();
     binding->propertyNameIndex = propertyNameIndex;
     binding->location.line = nameLocation.startLine;
index bf048ea60a929a1d7998fdfaa4d028116e7e77e2..dbb242804ad11d4816799997cadaf67328b58f5c 100644 (file)
@@ -5,4 +5,8 @@ MyContainer {
     MyTypeObject {
         id: "myObjectId"
     }
+
+    MyTypeObject {
+        selfGroupProperty.id: "name.with.dots"
+    }
 }
index 978c8ed08985ef470375f6b11728212f4d039a05..55d07e78da3d14aa7e62e6d6f2e2034dd2e45ff9 100644 (file)
@@ -1189,12 +1189,17 @@ void tst_qqmllanguage::idProperty()
     VERIFY_ERRORS(0);
     MyContainer *object = qobject_cast<MyContainer *>(component.create());
     QVERIFY(object != 0);
-    QCOMPARE(object->getChildren()->count(), 1);
+    QCOMPARE(object->getChildren()->count(), 2);
     MyTypeObject *child =
         qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
     QVERIFY(child != 0);
     QCOMPARE(child->id(), QString("myObjectId"));
     QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
+
+    child =
+        qobject_cast<MyTypeObject *>(object->getChildren()->at(1));
+    QVERIFY(child != 0);
+    QCOMPARE(child->id(), QString("name.with.dots"));
 }
 
 // Tests automatic connection to notify signals if "onBlahChanged" syntax is used