diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-22 06:47:18 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-22 06:53:44 (GMT) |
commit | 5efe6549e5248fbe5b20c8a18fec64d248d7b87c (patch) | |
tree | 9f5464b540a223d8905d893d132e9a1b8a47476e /tests | |
parent | 9490f107983197ca86e959d6470bd829a17642e5 (diff) | |
download | Qt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.zip Qt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.tar.gz Qt-5efe6549e5248fbe5b20c8a18fec64d248d7b87c.tar.bz2 |
Fix Loader crash.
If setting the source of a Loader triggered a change to the source
(i.e. the thing being loaded set the source to something else) a crash
would occur. We now no longer delete the component immediately when the
source changes.
Task-number: QTBUG-9241
Diffstat (limited to 'tests')
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeloader/data/BlueRect.qml b/tests/auto/declarative/qdeclarativeloader/data/BlueRect.qml new file mode 100644 index 0000000..3b49f6a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/BlueRect.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +Rectangle { + objectName: "blue" + width: 100 + height: 100 + color: "blue" +} diff --git a/tests/auto/declarative/qdeclarativeloader/data/GreenRect.qml b/tests/auto/declarative/qdeclarativeloader/data/GreenRect.qml new file mode 100644 index 0000000..7ee3513 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/GreenRect.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Rectangle { + width: 100; height: 100 + color: "green" + Component.onCompleted: myLoader.source = "BlueRect.qml" +} diff --git a/tests/auto/declarative/qdeclarativeloader/data/crash.qml b/tests/auto/declarative/qdeclarativeloader/data/crash.qml new file mode 100644 index 0000000..8474e78 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/crash.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + + function setLoaderSource() { + myLoader.source = "GreenRect.qml" + } + + Loader { + id: myLoader + } +} diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 61b2800..2c20836 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -88,6 +88,8 @@ private slots: void failNetworkRequest(); // void networkComponent(); + void deleteComponentCrash(); + private: QDeclarativeEngine engine; }; @@ -459,6 +461,28 @@ void tst_QDeclarativeLoader::failNetworkRequest() delete loader; } +// QTBUG-9241 +void tst_QDeclarativeLoader::deleteComponentCrash() +{ + QDeclarativeComponent component(&engine, TEST_FILE("/crash.qml")); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + + item->metaObject()->invokeMethod(item, "setLoaderSource"); + + QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(0)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->item()->objectName(), QLatin1String("blue")); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + QEXPECT_FAIL("", "QTBUG-9245", Continue); + QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml")); + + delete item; +} + QTEST_MAIN(tst_QDeclarativeLoader) #include "tst_qdeclarativeloader.moc" |