From 172d12c7a6daa036f477f0a76c787a0f76ac21b5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 30 Jan 2020 10:48:21 +0100 Subject: Force models and workerscript plugins to link their libraries Some linkers can determine that we don't use any symbols from the QtQmlModels and QtQmlWorkerScript libraries in the respective plugins and avoid to link the libraries into the plugins. That means, when loading the plugins, the types are not registered. We avoid that by adding a debug message that accesses a symbol of the library to each plugin. Change-Id: I3d946259df96382a3751eaafa12cbdd3d830c139 Fixes: QTBUG-81721 Reviewed-by: Fabian Kosmale --- src/imports/models/plugin.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/imports/models/plugin.cpp') diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp index d79b31bba5..4aa9f27766 100644 --- a/src/imports/models/plugin.cpp +++ b/src/imports/models/plugin.cpp @@ -37,13 +37,17 @@ ** ****************************************************************************/ +#include + #include #include -#include +#include QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(qmlModelsPlugin, "qt.qmlModelsPlugin") + /*! \qmlmodule QtQml.Models 2.\QtMinorVersion \title Qt QML Models QML Types @@ -86,7 +90,16 @@ class QtQmlModelsPlugin : public QQmlEngineExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) public: - QtQmlModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { } + QtQmlModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) + { + if (qmlModelsPlugin().isDebugEnabled()) { + // Superficial debug message that causes the dependency between QtQmlWorkerScript + // and the workerscript plugin to be retained. + // As qCDebug() can be a noop, retrieve the className in a separate step. + const QString className = QQmlObjectModel::staticMetaObject.className(); + qCDebug(qmlModelsPlugin) << "Loading QmlModels plugin:" << className; + } + } }; //![class decl] -- cgit v1.2.3