aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp
diff options
context:
space:
mode:
authorDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2025-03-05 13:17:09 +0100
committerDmitrii Akshintsev <dmitrii.akshintsev@qt.io>2025-03-18 11:28:27 +0100
commit30f030d03d5f8199757d5f4fb3bacbd7408204cc (patch)
tree6f74e9e875a3ec1bf4ff2eaea896c12f1422dd7e /tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp
parentf469d538a71a500a2b2cec6133065b780c3a8792 (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/invalidFirstCommandModule/plugin.cpp')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp
index c60161f424..bb9fbdddc4 100644
--- a/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/invalidFirstCommandModule/plugin.cpp
@@ -5,26 +5,22 @@
#include <QtQml/qqml.h>
#include <QDebug>
-class MyPluginType : public QObject
+class MyPluginTypeInvalidFirstCommand : public QObject
{
Q_OBJECT
-public:
- MyPluginType(QObject *parent=nullptr) : QObject(parent) {}
};
-
-class MyPlugin : public QQmlExtensionPlugin
+class MyPluginInvalidFirstCommand : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- MyPlugin() {}
-
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == "org.qtproject.InvalidFirstCommandModule");
- qmlRegisterType<MyPluginType>("org.qtproject.InvalidFirstCommandModule", 1, 0, "MyPluginType");
+ qmlRegisterType<MyPluginTypeInvalidFirstCommand>("org.qtproject.InvalidFirstCommandModule",
+ 1, 0, "MyPluginType");
}
};