From 50fe8dbed3adae3606bd2c32868821119b4f2808 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 24 Mar 2010 13:17:44 +1000 Subject: Output all Loader errors. Previously we were not outputting those that occurred on component->create(). --- src/declarative/graphicsitems/qdeclarativeloader.cpp | 2 ++ .../declarative/qdeclarativeloader/data/VmeError.qml | 7 +++++++ .../declarative/qdeclarativeloader/data/vmeErrors.qml | 6 ++++++ .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 18 ++++++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeloader/data/VmeError.qml create mode 100644 tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 4301467..2149da8 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -320,6 +320,8 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() delete ctxt; } } else { + if (!component->errors().isEmpty()) + qWarning() << component->errors(); delete obj; delete ctxt; source = QUrl(); diff --git a/tests/auto/declarative/qdeclarativeloader/data/VmeError.qml b/tests/auto/declarative/qdeclarativeloader/data/VmeError.qml new file mode 100644 index 0000000..da4f6cb --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/VmeError.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Rectangle { + width: 100; height: 100; color: "red" + signal somethingHappened + onSomethingHappened: QtObject {} +} diff --git a/tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml b/tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml new file mode 100644 index 0000000..782562b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Loader { + source: "VmeError.qml" +} + diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 7123dda..506e1ee 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -92,6 +92,7 @@ private slots: void deleteComponentCrash(); void nonItem(); + void vmeErrors(); private: QDeclarativeEngine engine; @@ -467,7 +468,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() // QTBUG-9241 void tst_QDeclarativeLoader::deleteComponentCrash() { - QDeclarativeComponent component(&engine, TEST_FILE("/crash.qml")); + QDeclarativeComponent component(&engine, TEST_FILE("crash.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); @@ -480,7 +481,6 @@ void tst_QDeclarativeLoader::deleteComponentCrash() QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QDeclarativeLoader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); - QEXPECT_FAIL("", "QTBUG-9245", Continue); QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml")); delete item; @@ -488,8 +488,7 @@ void tst_QDeclarativeLoader::deleteComponentCrash() void tst_QDeclarativeLoader::nonItem() { - QSKIP("QTBUG-9245", SkipAll); - QDeclarativeComponent component(&engine, TEST_FILE("/nonItem.qml")); + QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); QTest::ignoreMessage(QtWarningMsg, "QML Loader (file://" SRCDIR "/data/nonItem.qml:3:1) Loader does not support loading non-visual elements."); QDeclarativeLoader *loader = qobject_cast(component.create()); QVERIFY(loader); @@ -498,6 +497,17 @@ void tst_QDeclarativeLoader::nonItem() delete loader; } +void tst_QDeclarativeLoader::vmeErrors() +{ + QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml")); + QTest::ignoreMessage(QtWarningMsg, "(file://" SRCDIR "/data/VmeError.qml:6: Cannot assign object type QObject with no default method\n onSomethingHappened: QtObject {}) "); + QDeclarativeLoader *loader = qobject_cast(component.create()); + QVERIFY(loader); + QVERIFY(loader->item() == 0); + + delete loader; +} + void tst_QDeclarativeLoader::networkSafety_data() { QTest::addColumn("url"); -- cgit v0.12