aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/workerscript
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-31 16:05:52 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-02-04 11:07:15 +0100
commitac46c9f6ce9ef757e0ccba8a283cb0efabaef56e (patch)
tree9c2768c78fb5cc37024d5518115f1b7998f5f72b /src/imports/workerscript
parent6e111f96e307501ec02a620fa3124fd3ce9c9193 (diff)
Synthetically reference type registration functions
Add unused volatile pointers to the type registration functions in each import plugin. We need to do this in order to prevent the linker from optimizing the registration away. There are two ways for this to happen: When linking statically, the linker will examine the referenced symbols on a per-object base and leave out all unreferenced objects. When linking dynamically, the linker may do the same on a per-library base and drop any unreferenced libraries from the dependencies. Forcing a reference to the type registration function prevents both. The volatile technique allows us to remove the previous qCDebug() hack. Having an unused volatile auto variable should only result in a single memory read as runtime overhead. The qCDebug() technique would generate a read and a block of mostly dead code (as no one would ever use that logging category). Fixes: QTBUG-81622 Change-Id: I255667276dfd355b19baa17b1aad3db406bf1954 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/imports/workerscript')
-rw-r--r--src/imports/workerscript/plugin.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/imports/workerscript/plugin.cpp b/src/imports/workerscript/plugin.cpp
index 0961979c53..1323b17ef4 100644
--- a/src/imports/workerscript/plugin.cpp
+++ b/src/imports/workerscript/plugin.cpp
@@ -37,17 +37,11 @@
**
****************************************************************************/
-#include <QtQmlWorkerScript/private/qquickworkerscript_p.h>
-
+#include <QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h>
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
-
-#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(workerScriptPlugin, "qt.workerScriptPlugin")
-
/*!
\qmlmodule QtQml.WorkerScript 2.\QtMinorVersion
\title Qt QML WorkerScript QML Types
@@ -71,13 +65,8 @@ class QtQmlWorkerScriptPlugin : public QQmlEngineExtensionPlugin
public:
QtQmlWorkerScriptPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
- if (workerScriptPlugin().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 = QQuickWorkerScript::staticMetaObject.className();
- qCDebug(workerScriptPlugin) << "Loading WorkerScript plugin:" << className;
- }
+ volatile auto registration = &qml_register_types_QtQml_WorkerScript;
+ Q_UNUSED(registration);
}
};