diff options
| author | Dmitrii Akshintsev <dmitrii.akshintsev@qt.io> | 2025-03-05 13:17:09 +0100 |
|---|---|---|
| committer | Dmitrii Akshintsev <dmitrii.akshintsev@qt.io> | 2025-03-18 11:28:27 +0100 |
| commit | 30f030d03d5f8199757d5f4fb3bacbd7408204cc (patch) | |
| tree | 6f74e9e875a3ec1bf4ff2eaea896c12f1422dd7e /tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp | |
| parent | f469d538a71a500a2b2cec6133065b780c3a8792 (diff) | |
qtdeclarative: fix tst_qqmlmoduleplugin when statically built
This test was written before the qt_add_qml_module, plugins were manually
written with a help of a deprecated QQmlExtensionPlugin.
Assuming that plugins are, by nature, dynamic objects to be loaded at a runtime,
this test was not intended to cover cases when plugins are statically built and linked into the test.
The fix consists of the following:
1. Introduction of conditional macro definition QT_STATICPLUGIN for static builds.
Based on this macro, MOC in it's turn, generates qt_static_plugin_##PLUGIN() symbols
2. Preventing symbol clashes (ODR violation) in static builds by renaming Plugin and type names.
3. Preventing linker optimizations by explicitly referencing MOC-generated
qt_static_plugin_##PLUGIN symbols through Q_IMPORT_QML_PLUGIN.
4. Making static plugins "findable" by Pluginimporter by passing uri as a moc option
5. Minor refactoring of the tests:
a) make "non-strict clash" test isolated (not relying on the previous state of execution)
b) unite importsPlugin and importsChildPlugin
More context on the "-Muri" MOC option
e8c4af1ac5429dba8062dbe7702746af96e8fdef
0d4f698c80e5e63f790771a369aa6a1fa987c41e
Fixes: QTBUG-131812
Pick-to: 6.8 6.9
Change-Id: I6582c393182b80aeb1f01c1fa93417e1d4f316c9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp')
| -rw-r--r-- | tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp index 858b2b4704..9bddf0f0c4 100644 --- a/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/nestedPlugin/nestedPlugin.cpp @@ -5,14 +5,12 @@ #include <QtQml/qqml.h> #include <QDebug> -class MyPluginType : public QObject +class MyPluginTypeNested : public QObject { Q_OBJECT Q_PROPERTY(QString value READ value) public: - MyPluginType(QObject *parent=nullptr) : QObject(parent) {} - QString value() const { return "Hello"; } }; @@ -22,24 +20,19 @@ class MyNestedPluginType : public QObject Q_PROPERTY(QString value READ value) public: - MyNestedPluginType(QObject *parent=nullptr) : QObject(parent) {} - QString value() const { return "Goodbye"; } }; - -class MyPlugin : public QQmlExtensionPlugin +class MyPluginNested : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - MyPlugin() {} - void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlNestedPluginType"); - qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType"); + qmlRegisterType<MyPluginTypeNested>(uri, 1, 0, "MyPluginType"); QString nestedUri(uri); nestedUri += QLatin1String(".Nested"); |
