From 61159419e3862042e97f01bde944e385313a409c Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 14 Jul 2021 15:48:30 +0200 Subject: Introduce Q_IMPORT_QML_PLUGIN In Qt 6.2, Q_IMPORT_QML_PLUGIN behaves exactly the same as Q_IMPORT_PLUGIN. The goal is however to make it obsolete in the future, by taking care of the plugin handling purely in CMake. The idea is to have Q_IMPORT_QML_PLUGIN expand to nothing in a later release; having the additional layer indirection via Q_IMPORT_QML_PLUGIN allows that change, which would be impossible if we were to directly use Q_IMPORT_PLUGIN. Having the macro later expand to nothing is required because otherwise we might attempt to instantiate a static plugin instance with the same name twice, leading to duplicated symbol errors. Task-number: QTBUG-95148 Change-Id: I29bf4637f37d6358f07935c476544888c1c4c023 Reviewed-by: Ulf Hermann Reviewed-by: Andrei Golubev (cherry picked from commit 9ac0a380b07c5da0ec0d7224cc8fe5ac21e97676) Reviewed-by: Qt Cherry-pick Bot --- src/qml/qml/qqmlextensionplugin.cpp | 9 +++++++++ src/qml/qml/qqmlextensionplugin.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp index f779199b74..14704a0442 100644 --- a/src/qml/qml/qqmlextensionplugin.cpp +++ b/src/qml/qml/qqmlextensionplugin.cpp @@ -165,6 +165,15 @@ void QQmlEngineExtensionPlugin::initializeEngine(QQmlEngine *engine, const char \inmodule QtQml */ + +/*! + \macro Q_IMPORT_QML_PLUGIN(PluginName) + \relates + + Ensures that a QML plugin works in static builds. + \sa Q_IMPORT_PLUGIN +*/ + QT_END_NAMESPACE #include "moc_qqmlextensionplugin.cpp" diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h index 78371106bd..afd58e4032 100644 --- a/src/qml/qml/qqmlextensionplugin.h +++ b/src/qml/qml/qqmlextensionplugin.h @@ -44,6 +44,9 @@ #include #include +#define Q_IMPORT_QML_PLUGIN(PLUGIN) \ + Q_IMPORT_PLUGIN(PLUGIN) + QT_BEGIN_NAMESPACE class QQmlEngine; -- cgit v1.2.3