From c6a2d3155c58254301fa29cdbf08d36962da57c1 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 3 Jul 2024 13:06:41 +0200 Subject: [PATCH] Mac style: remove appearance observer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have one in the theme already. If that observer gets called we update the palette from the system, and let the style polish the palettes. So we can clear the cached cocoa controls when the palette gets polished. Change-Id: I1dcfba67ca0d60f79741c0a0cf0d07c9fd217a9e Reviewed-by: Tor Arne Vestbø (cherry picked from commit cb9f5b5d0a538e69dbb099c5c8069fa8716e03cf) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/styles/mac/qmacstyle_mac.mm | 15 ++++----------- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 226da495f43..353fd68adfa 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2009,17 +2009,6 @@ QMacStyle::QMacStyle() for (const auto &o : QMacStylePrivate::scrollBars) QCoreApplication::sendEvent(o, &event); }); - - Q_D(QMacStyle); - // FIXME: Tie this logic into theme change, or even polish/unpolish - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSMojave) { - d->appearanceObserver = QMacKeyValueObserver(NSApp, @"effectiveAppearance", [this] { - Q_D(QMacStyle); - for (NSView *b : d->cocoaControls) - [b release]; - d->cocoaControls.clear(); - }); - } } QMacStyle::~QMacStyle() @@ -2028,6 +2017,10 @@ QMacStyle::~QMacStyle() void QMacStyle::polish(QPalette &) { + Q_D(QMacStyle); + for (NSView *b : d->cocoaControls) + [b release]; + d->cocoaControls.clear(); } void QMacStyle::polish(QApplication *) diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index 0dcfce2f0ca..798d7c38b7b 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -263,7 +263,6 @@ public: std::optional smallSystemFont; - QMacKeyValueObserver appearanceObserver; }; QT_END_NAMESPACE