diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 26cb075ca8d..d2a1625bf71 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -376,7 +376,8 @@ QPlatformThemePrivate::QPlatformThemePrivate() QPlatformThemePrivate::~QPlatformThemePrivate() { - delete systemPalette; + if (systemPalette) + delete systemPalette; } Q_GUI_EXPORT QPalette qt_fusionPalette() @@ -476,8 +477,22 @@ Qt::ColorScheme QPlatformTheme::colorScheme() const void QPlatformTheme::requestColorScheme(Qt::ColorScheme scheme) { Q_UNUSED(scheme); + Q_D(QPlatformTheme); + if (d->systemPalette) { + delete d->systemPalette; + d->systemPalette = nullptr; + } } +/*! + \internal + \brief Return a color palette for type \a type. + + When relying on system color palette keep in mind that it is + lazily initialized and cached. If it needs to be updated + (i.e. due to ColorScheme changes), it's up to the caller + to take care of it. See \c requestColorScheme. +*/ const QPalette *QPlatformTheme::palette(Palette type) const { Q_D(const QPlatformTheme); diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index ec54872347e..25decb235b7 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -165,6 +165,7 @@ void QGtk3Theme::requestColorScheme(Qt::ColorScheme scheme) return; qCDebug(lcQGtk3Interface) << scheme << "has been requested. Theme supports color scheme:" << m_storage->colorScheme(); + QPlatformTheme::requestColorScheme(scheme); m_requestedColorScheme = scheme; m_storage->handleThemeChange(); }