From 164af37710e5721cbc7d79a0af20f2387181c59c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 16 Oct 2015 17:21:55 +0200 Subject: Load component synchronously in method_createQmlObject setData() is not guaranteed to synchronously load the type. In fact, most of the time, it doesn't. However, by adding a private Synchronous mode to QQmlTypeLoader we can prefetch the type synchronously and then inject it into the component. Task-number: QTBUG-45418 Change-Id: I640f12ad20c01b778b5bc41f43574d8aea504195 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp') diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 77cdaae9f0..4c5b1f7e63 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -43,6 +43,7 @@ class tst_QQMLTypeLoader : public QQmlDataTest private slots: void testLoadComplete(); + void loadComponentSynchronously(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -62,6 +63,16 @@ void tst_QQMLTypeLoader::testLoadComplete() delete window; } +void tst_QQMLTypeLoader::loadComponentSynchronously() +{ + QQmlEngine engine; + QTest::ignoreMessage(QtWarningMsg, QRegularExpression( + QLatin1String(".*nonprotocol::1:1: QtObject is not a type.*"))); + QQmlComponent component(&engine, testFileUrl("load_synchronous.qml")); + QObject *o = component.create(); + QVERIFY(o); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" -- cgit v1.2.3