diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-18 05:27:05 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-21 23:11:26 (GMT) |
commit | b5d5be9db8ea0932b728fb9b90f61212c7cb6777 (patch) | |
tree | 67a088dc4f5baefb2dfe127ed4bfdd487eef69a0 /tests/auto | |
parent | 535172df73b539bf6468a96773ac28457e307792 (diff) | |
download | Qt-b5d5be9db8ea0932b728fb9b90f61212c7cb6777.zip Qt-b5d5be9db8ea0932b728fb9b90f61212c7cb6777.tar.gz Qt-b5d5be9db8ea0932b728fb9b90f61212c7cb6777.tar.bz2 |
Fix crash when calling createObject on a component with errors.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml index ed5e571..2fef03a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml @@ -18,4 +18,10 @@ MyQmlObject{ { obj.objectProperty = createQmlObject('TypeForDynamicCreation{}', obj); } + + function dontCrash() + { + var component = createComponent('file-doesnt-exist.qml'); + obj.objectProperty = component.createObject(); + } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index caefdbf..87d73a0 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -130,6 +130,7 @@ private slots: void qlistqobjectMethods(); void bug1(); + void dynamicCreationCrash(); void callQtInvokables(); private: @@ -1227,6 +1228,19 @@ void tst_qdeclarativeecmascript::bug1() delete object; } +// Don't crash in createObject when the component has errors. +void tst_qdeclarativeecmascript::dynamicCreationCrash() +{ + QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); + QMetaObject::invokeMethod(object, "dontCrash"); + QObject *created = object->objectProperty(); + QVERIFY(created == 0); +} + void tst_qdeclarativeecmascript::callQtInvokables() { MyInvokableObject o; |