diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-04-03 17:20:18 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-04 17:26:20 +0200 |
commit | 2ee0b6ed788325cad73c3646ab2d72eadeeb1b0c (patch) | |
tree | a707c07143024b3fbe956f429d4daa5f5bf5ce60 | |
parent | 873f927fe225e2da9870997c73497c528e77e210 (diff) |
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 <lars.knoll@digia.com>
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/idProperty.qml | 4 | ||||
-rw-r--r-- | 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>(); 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<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 |