From 2ee0b6ed788325cad73c3646ab2d72eadeeb1b0c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 3 Apr 2014 17:20:18 +0200 Subject: Regression: Fix id objects in group properties 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 --- src/qml/compiler/qqmlirbuilder.cpp | 9 ++++----- tests/auto/qml/qqmllanguage/data/idProperty.qml | 4 ++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 1c10a49fd1..0dac79f6e7 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -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->propertyNameIndex = propertyNameIndex; binding->location.line = nameLocation.startLine; diff --git a/tests/auto/qml/qqmllanguage/data/idProperty.qml b/tests/auto/qml/qqmllanguage/data/idProperty.qml index bf048ea60a..dbb242804a 100644 --- a/tests/auto/qml/qqmllanguage/data/idProperty.qml +++ b/tests/auto/qml/qqmllanguage/data/idProperty.qml @@ -5,4 +5,8 @@ MyContainer { MyTypeObject { id: "myObjectId" } + + MyTypeObject { + selfGroupProperty.id: "name.with.dots" + } } diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 978c8ed089..55d07e78da 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -1189,12 +1189,17 @@ void tst_qqmllanguage::idProperty() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 1); + QCOMPARE(object->getChildren()->count(), 2); MyTypeObject *child = qobject_cast(object->getChildren()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); + + child = + qobject_cast(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 -- cgit v1.2.3