Mac style: remove appearance observer

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ø <tor.arne.vestbo@qt.io>
(cherry picked from commit cb9f5b5d0a538e69dbb099c5c8069fa8716e03cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-07-03 13:06:41 +02:00 committed by Qt Cherry-pick Bot
parent 24f26ca9bb
commit c6a2d3155c
2 changed files with 4 additions and 12 deletions

View File

@ -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 *)

View File

@ -263,7 +263,6 @@ public:
std::optional<QFont> smallSystemFont;
QMacKeyValueObserver appearanceObserver;
};
QT_END_NAMESPACE