aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@qt.io>2020-11-13 10:24:50 +0100
committerFawzi Mohamed <fawzi.mohamed@qt.io>2020-11-16 10:33:36 +0100
commite99cfb21d6018b36cdbc9832f9ce107569a92bf3 (patch)
treeb1c6fac1e21fa7449b725271e515d7449c51e339
parent182b858a69def93090a1fc37660b2b07ae8423d5 (diff)
Fix static build using native styles
Ensure that the qml registration function of macOS, Windows and native styles get linked and executed in static builds by referencing the initialization function in the plugin constructor. This is intrusive and ugly, but is the method currently used in other plugins. Fixes: QTBUG-88463 Change-Id: I1b41ec89116066f46818f40ad155d12f6e719ca7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/imports/controls/macos/qtquickcontrols2macosstyleplugin.cpp11
-rw-r--r--src/imports/controls/windows/qtquickcontrols2windowsstyleplugin.cpp10
-rw-r--r--src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp10
3 files changed, 31 insertions, 0 deletions
diff --git a/src/imports/controls/macos/qtquickcontrols2macosstyleplugin.cpp b/src/imports/controls/macos/qtquickcontrols2macosstyleplugin.cpp
index f97414ce..9a4fd0ce 100644
--- a/src/imports/controls/macos/qtquickcontrols2macosstyleplugin.cpp
+++ b/src/imports/controls/macos/qtquickcontrols2macosstyleplugin.cpp
@@ -38,6 +38,8 @@
#include <QtQuickControls2/private/qquickstyleplugin_p.h>
#include <QtQuickControls2/qquickstyle.h>
+extern void qml_register_types_QtQuick_Controls_macOS();
+
QT_BEGIN_NAMESPACE
class QtQuickControls2MacOSStylePlugin : public QQuickStylePlugin
@@ -46,10 +48,19 @@ class QtQuickControls2MacOSStylePlugin : public QQuickStylePlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
+ QtQuickControls2MacOSStylePlugin(QObject *parent = nullptr);
QString name() const override;
void initializeTheme(QQuickTheme *theme) override;
};
+
+QtQuickControls2MacOSStylePlugin::QtQuickControls2MacOSStylePlugin(QObject *parent):
+ QQuickStylePlugin(parent)
+{
+ volatile auto registration = &qml_register_types_QtQuick_Controls_macOS;
+ Q_UNUSED(registration);
+}
+
QString QtQuickControls2MacOSStylePlugin::name() const
{
return QStringLiteral("macOS");
diff --git a/src/imports/controls/windows/qtquickcontrols2windowsstyleplugin.cpp b/src/imports/controls/windows/qtquickcontrols2windowsstyleplugin.cpp
index 1136cd9a..c893d93e 100644
--- a/src/imports/controls/windows/qtquickcontrols2windowsstyleplugin.cpp
+++ b/src/imports/controls/windows/qtquickcontrols2windowsstyleplugin.cpp
@@ -38,6 +38,8 @@
#include <QtQuickControls2/private/qquickstyleplugin_p.h>
#include <QtQuickControls2/qquickstyle.h>
+extern void qml_register_types_QtQuick_Controls_Windows();
+
QT_BEGIN_NAMESPACE
class QtQuickControls2WindowsStylePlugin : public QQuickStylePlugin
@@ -46,10 +48,18 @@ class QtQuickControls2WindowsStylePlugin : public QQuickStylePlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
+ QtQuickControls2WindowsStylePlugin(QObject *parent = nullptr);
QString name() const override;
void initializeTheme(QQuickTheme *theme) override;
};
+QtQuickControls2WindowsStylePlugin::QtQuickControls2WindowsStylePlugin(QObject *parent):
+ QQuickStylePlugin(parent)
+{
+ volatile auto registration = &qml_register_types_QtQuick_Controls_Windows;
+ Q_UNUSED(registration);
+}
+
QString QtQuickControls2WindowsStylePlugin::name() const
{
return QStringLiteral("Windows");
diff --git a/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp b/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
index cf9b5ccf..7b638704 100644
--- a/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
+++ b/src/imports/nativestyle/qtquickcontrols2nativestyleplugin.cpp
@@ -50,6 +50,8 @@
# include "qquickwindowsxpstyle_p.h"
#endif
+extern void qml_register_types_QtQuick_NativeStyle();
+
QT_BEGIN_NAMESPACE
using namespace QQC2;
@@ -60,6 +62,7 @@ class QtQuickControls2NativeStylePlugin : public QQuickStylePlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
+ QtQuickControls2NativeStylePlugin(QObject *parent = nullptr);
~QtQuickControls2NativeStylePlugin() override;
void initializeEngine(QQmlEngine *engine, const char *uri) override;
@@ -85,6 +88,13 @@ static void deleteQStyle()
QQuickNativeStyle::setStyle(nullptr);
}
+QtQuickControls2NativeStylePlugin::QtQuickControls2NativeStylePlugin(QObject *parent):
+ QQuickStylePlugin(parent)
+{
+ volatile auto registration = &qml_register_types_QtQuick_NativeStyle;
+ Q_UNUSED(registration);
+}
+
QtQuickControls2NativeStylePlugin::~QtQuickControls2NativeStylePlugin()
{
if (!qGuiApp)