diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-10-08 01:06:34 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-10-08 01:06:34 (GMT) |
commit | 8480eb288990c44c9ab337f42898bc4ef6dc62f4 (patch) | |
tree | c6b81875d9da441b825e4a6ae6996105896526c1 | |
parent | 33245164dc62d27f88a8914d1112f3a4155fa174 (diff) | |
download | Qt-8480eb288990c44c9ab337f42898bc4ef6dc62f4.zip Qt-8480eb288990c44c9ab337f42898bc4ef6dc62f4.tar.gz Qt-8480eb288990c44c9ab337f42898bc4ef6dc62f4.tar.bz2 |
Don't allow multiple values to be assigned to a singular property
Task-number: QTBUG-14005
7 files changed, 26 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index dc28e22..7a29f24 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1932,6 +1932,9 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property { obj->addValueProperty(prop); + if (prop->values.count() > 1) + COMPILE_EXCEPTION(prop->values.at(0), tr( "Cannot assign multiple values to a singular property") ); + for (int ii = 0; ii < prop->values.count(); ++ii) { Value *v = prop->values.at(ii); if (v->object) { diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index 9fca5c3..56ac216 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -7,9 +7,9 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" Behavior on x { + id: myBehavior objectName: "MyBehavior" NumberAnimation {id: na1; duration: 200 } - NumberAnimation {id: na2; duration: 1000 } } } MouseArea { @@ -24,4 +24,9 @@ Rectangle { x: 200 } } + + NumberAnimation {id: na2; duration: 1000 } + Component.onCompleted: { + myBehavior.animation = na2; + } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt new file mode 100644 index 0000000..beae562 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml new file mode 100644 index 0000000..2fd7fd2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +QtObject { + property QtObject a + a: [ QtObject {}, QtObject {} ] +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt new file mode 100644 index 0000000..beae562 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml new file mode 100644 index 0000000..da56cb8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml @@ -0,0 +1,6 @@ +import QtQuick 1.0 + +QtObject { + property variant a + a: [ QtObject {}, QtObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 9a8c944..bb1312b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -380,6 +380,8 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false; QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; + QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; + QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; } |