diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-19 01:45:47 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-21 23:04:58 (GMT) |
commit | 0c1f1b8c8f5641609e1a07622127f4e0780c2247 (patch) | |
tree | f59b4736cd7563d1df75bbbbd604218e791c89e1 | |
parent | 44b1fc2051df2bfd784ce847ee430edad68e3dbd (diff) | |
download | Qt-0c1f1b8c8f5641609e1a07622127f4e0780c2247.zip Qt-0c1f1b8c8f5641609e1a07622127f4e0780c2247.tar.gz Qt-0c1f1b8c8f5641609e1a07622127f4e0780c2247.tar.bz2 |
Produce an error when trying to create objects in a PropertyChanges.
State-specific object lifecycle management will be addressed in a
future release.
Task-number: QTBUG-8318
3 files changed, 28 insertions, 0 deletions
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index 8865e04..6ceec5d 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -227,6 +227,8 @@ QDeclarativePropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> const QVariant &value = values.at(ii); if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) { + error(qvariant_cast<QDeclarativeCustomParserNode>(value), + QDeclarativePropertyChanges::tr("PropertyChanges does not support creating state-specific objects.")); continue; } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) { diff --git a/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml b/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml new file mode 100644 index 0000000..480764e --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Rectangle { + id: myItem + + states : State { + PropertyChanges { + target: myItem + children: Item { id: newItem } + } + } +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index fe7ec15..9e1d727 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -106,6 +106,7 @@ private slots: void illegalTempState(); void nonExistantProperty(); void reset(); + void illegalObjectCreation(); }; void tst_qdeclarativestates::initTestCase() @@ -964,6 +965,19 @@ void tst_qdeclarativestates::reset() QVERIFY(text->width() > text->height()); } +void tst_qdeclarativestates::illegalObjectCreation() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent component(&engine, SRCDIR "/data/illegalObj.qml"); + QList<QDeclarativeError> errors = component.errors(); + QVERIFY(errors.count() == 1); + const QDeclarativeError &error = errors.at(0); + QCOMPARE(error.line(), 9); + QCOMPARE(error.column(), 23); + QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); +} + QTEST_MAIN(tst_qdeclarativestates) #include "tst_qdeclarativestates.moc" |