aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/fusion
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-08-28 16:55:25 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-09-24 13:48:39 +0200
commit74acbcc9f31aa2c64d076e1157979537d90d3f6d (patch)
treec896835ef345e8663aee2b6bf4b13e5779a6fd58 /src/imports/controls/fusion
parent6059a7765b123a6f3fb221db9674a995bae1881c (diff)
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 <richard.gustavsen@qt.io>
Diffstat (limited to 'src/imports/controls/fusion')
-rw-r--r--src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp12
1 files changed, 3 insertions, 9 deletions
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