aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/models/plugin.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-30 10:48:21 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-01-30 12:43:33 +0100
commit172d12c7a6daa036f477f0a76c787a0f76ac21b5 (patch)
tree08ff307aee1dc8f74c934e934e509065b7dc990e /src/imports/models/plugin.cpp
parentc5f78add12b7d33926631b6df79599df18f65068 (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/imports/models/plugin.cpp')
-rw-r--r--src/imports/models/plugin.cpp17
1 files changed, 15 insertions, 2 deletions
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 <QtQmlModels/private/qqmlobjectmodel_p.h>
+
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-#include <private/qqmlmodelsmodule_p.h>
+#include <QtCore/qloggingcategory.h>
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]