diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-06-02 16:50:20 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-06-09 08:01:02 +0200 |
commit | 5dc14c88f9510795835fb4f0a0d46d67c40f7020 (patch) | |
tree | 937173d548a6ad0d4c46cf75914adb6f6b140254 /tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | |
parent | 6a48a81319b886c8a3f85e1eb024186b05d0f3af (diff) |
Allow QML plugins to be optional
If a plugin does nothing but load the library that provides the types,
we can skip the plugin loading by linking the library directly. State
that in the qmldir file, and evaluate it when loading the module.
Task-number: QTBUG-84639
Change-Id: I2097237866a50f66c55e4653ad119fe10e18a893
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp')
-rw-r--r-- | tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index f15d53d022..3590eeb768 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -39,6 +39,8 @@ #include <QCborValue> #endif +#include <QtQuickShapes/private/qquickshapesglobal_p.h> + #if defined(Q_OS_MAC) // For _PC_CASE_SENSITIVE #include <unistd.h> @@ -83,6 +85,7 @@ private slots: void importsChildPlugin21(); void parallelPluginImport(); void multiSingleton(); + void optionalPlugin(); private: QString m_importsDirectory; @@ -805,6 +808,20 @@ void tst_qqmlmoduleplugin::multiSingleton() delete object; } +void tst_qqmlmoduleplugin::optionalPlugin() +{ + // Force QtQuickShapes to be linked. + volatile auto registration = &qml_register_types_QtQuick_Shapes; + Q_UNUSED(registration); + + QQmlEngine engine; + engine.setImportPathList({m_importsDirectory}); + QQmlComponent component(&engine); + component.setData("import QtQuick.Shapes\nShapePath {}\n", QUrl()); + QScopedPointer<QObject> object10(component.create()); + QVERIFY(!object10.isNull()); +} + QTEST_MAIN(tst_qqmlmoduleplugin) |