diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-20 04:49:36 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-20 04:49:36 (GMT) |
commit | 78c78085449149b5c48bbecd49424974cdf79bee (patch) | |
tree | c56b323d7270bb3515d2d7277e366a8fa2e76e34 /tests | |
parent | 27b09c283d68fa4b1eae32f82a1041bca1a28656 (diff) | |
download | Qt-78c78085449149b5c48bbecd49424974cdf79bee.zip Qt-78c78085449149b5c48bbecd49424974cdf79bee.tar.gz Qt-78c78085449149b5c48bbecd49424974cdf79bee.tar.bz2 |
Allow null to be assigned to object properties
Diffstat (limited to 'tests')
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml new file mode 100644 index 0000000..3fd9131 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml @@ -0,0 +1,9 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool runTest: false + + property variant a: MyQmlObject {} + + objectProperty: (runTest == false)?a:null +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml new file mode 100644 index 0000000..19b0c42 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import Qt 4.6 + +MyQmlObject { + objectProperty: MyQmlObject {} + + Component.onCompleted: { + objectProperty = null; + } +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index a2ecf74..6939290 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -141,6 +141,7 @@ private slots: void variantsAssignedUndefined(); void qtbug_9792(); void noSpuriousWarningsAtShutdown(); + void canAssignNullToQObject(); void callQtInvokables(); private: @@ -2190,6 +2191,35 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() } } +void tst_qdeclarativeecmascript::canAssignNullToQObject() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.1.qml")); + + MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(o != 0); + + QVERIFY(o->objectProperty() != 0); + + o->setProperty("runTest", true); + + QVERIFY(o->objectProperty() == 0); + + delete o; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.2.qml")); + + MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(o != 0); + + QVERIFY(o->objectProperty() == 0); + + delete o; + } +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" |