From 74acbcc9f31aa2c64d076e1157979537d90d3f6d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 28 Aug 2020 16:55:25 +0200 Subject: Fix fallback styles overwriting themes In Qt 5, QtQuickControls2Plugin::registerTypes() was responsible for calling initializeTheme() on each style plugin. Now that we delegate more work to the QML engine, each style plugin calls initializeTheme() via registerTypes(). To avoid fallback styles overwriting font and palette data set by the current style, we need to check if the theme has been intialized before calling initializeTheme(). To do this, we add a static "themeInitialized" bool that QQuickStylePlugin sets to true after calling intializeTheme() for the first time. It checks this value and avoids calling intializeTheme() if it's true. We also need to make QQuickStylePlugin ensure that the theme it's initializing belongs to the current style. Fixes: QTBUG-86303 Change-Id: Ie65e646677c78622829f4949c41cb79204cf5786 Reviewed-by: Richard Moe Gustavsen --- .../controls/fusion/qtquickcontrols2fusionstyleplugin.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/imports/controls/fusion') diff --git a/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp index 59d99afc..fcaa959e 100644 --- a/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp +++ b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp @@ -52,8 +52,7 @@ public: QtQuickControls2FusionStylePlugin(QObject *parent = nullptr); QString name() const override; - - void registerTypes(const char *uri) override; + void initializeTheme(QQuickTheme *theme) override; QQuickFusionTheme theme; }; @@ -67,14 +66,9 @@ QString QtQuickControls2FusionStylePlugin::name() const return QStringLiteral("Fusion"); } -void QtQuickControls2FusionStylePlugin::registerTypes(const char *uri) +void QtQuickControls2FusionStylePlugin::initializeTheme(QQuickTheme *theme) { - QQuickStylePlugin::registerTypes(uri); - - if (!QQuickTheme::instance()) - return; - - theme.initialize(QQuickTheme::instance()); + this->theme.initialize(theme); } QT_END_NAMESPACE -- cgit v1.2.3