From 161c5693143783e0364d32c587497669747efc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 6 Dec 2018 14:46:26 +0100 Subject: macOS: Reset font glyph caches when application theme changes Our glyph caches on 10.14 are based on the application appearance, so when the application goes from dark to light or light to dark, we need to reset and re-populate the glyph-caches to account for the new appearance. Change-Id: If019d8cfa33ffb2b14747444b2ff74b288992f55 Fixes: QTBUG-71018 Reviewed-by: Timur Pocheptsov --- src/gui/text/qfont_p.h | 2 +- src/plugins/platforms/cocoa/qcocoatheme.mm | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 350ba7ce3c..c5847f532b 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -210,7 +210,7 @@ private: }; -class Q_AUTOTEST_EXPORT QFontCache : public QObject +class Q_GUI_EXPORT QFontCache : public QObject { public: // note: these static functions work on a per-thread basis diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index a2229159b5..240deeddbd 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -53,11 +53,13 @@ #include "qcocoahelpers.h" #include +#include #include #include #include #include #include +#include #include #include #include @@ -162,6 +164,11 @@ void QCocoaTheme::handleSystemThemeChange() m_systemPalette = qt_mac_createSystemPalette(); m_palettes = qt_mac_createRolePalettes(); + if (QCoreTextFontEngine::fontSmoothing() == QCoreTextFontEngine::FontSmoothing::Grayscale) { + // Re-populate glyph caches based on the new appearance's assumed text fill color + QFontCache::instance()->clear(); + } + QWindowSystemInterface::handleThemeChange(nullptr); } -- cgit v1.2.3