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/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp | |
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/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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" |