diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-27 03:37:59 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-27 03:37:59 (GMT) |
commit | 76ece6b01e88199349e4c98897b5a846e8253c9d (patch) | |
tree | 1be9cd73f41c7c95d4d5821df3ce523369898894 /tests | |
parent | e22a3c2ba8fae9514b5adcc35e8215caf3812871 (diff) | |
download | Qt-76ece6b01e88199349e4c98897b5a846e8253c9d.zip Qt-76ece6b01e88199349e4c98897b5a846e8253c9d.tar.gz Qt-76ece6b01e88199349e4c98897b5a846e8253c9d.tar.bz2 |
Don't crash when requesting an attached object for non-QML object
Diffstat (limited to 'tests')
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml new file mode 100644 index 0000000..99a9746 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import Qt 4.6 +Object { +} + diff --git a/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml new file mode 100644 index 0000000..8179dbd --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import Qt 4.6 +Object { + MyQmlObject.value: 10 +} + diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 4bc02c0..5ef1a7d 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -74,6 +74,8 @@ private slots: void importsOrder_data(); void importsOrder(); + void qmlAttachedPropertiesObjectMethod(); + // regression tests for crashes void crash1(); @@ -1012,6 +1014,34 @@ void tst_qmllanguage::importsOrder() testType(qml,type); } +void tst_qmllanguage::qmlAttachedPropertiesObjectMethod() +{ + QObject object; + + QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0); + QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0); + + { + QmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0); + QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0); + } + + { + QmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0); + QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0); + } +} + void tst_qmllanguage::crash1() { QmlComponent component(&engine, "Component {}"); |