summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoatheme.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-05-29 16:36:09 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-05-29 17:11:40 +0200
commitb53994de5f1b641ca2f6c79048339ff34fe14b55 (patch)
tree4c6c1fe9cc8ff91a8ac563d06cfbb1edcd5218e7 /src/plugins/platforms/cocoa/qcocoatheme.mm
parent15d73a9f479e88af85944119e79d88ed26d4f346 (diff)
macOS: Use QMacNotificationObserver over manual notification handling
This also fixes a bug where we were implicitly capturing this inside the block, which meant that we would crash if the theme was recreated. The capture is now tied to the lifetime of QCocoaTheme. Change-Id: I37df8e6c0b33bf41e76d66be3cf29576041a7546 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoatheme.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index efe670abed..ba93560689 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -133,10 +133,10 @@ QCocoaTheme::QCocoaTheme()
m_appearanceObserver = [[QCocoaThemeAppAppearanceObserver alloc] initWithTheme:this];
#endif
- [[NSNotificationCenter defaultCenter] addObserverForName:NSSystemColorsDidChangeNotification
- object:nil queue:nil usingBlock:^(NSNotification *) {
+ m_systemColorObserver = QMacNotificationObserver(nil,
+ NSSystemColorsDidChangeNotification, [this] {
handleSystemThemeChange();
- }];
+ });
}
QCocoaTheme::~QCocoaTheme()