Pass on NSNotification to QMacNotificationObserver callbacks if supported

Change-Id: I167f2e24453a2f2c75b81207f7293c72243f5a7a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c7c830057589a91cc369375775d018c5057ba46a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-17 15:35:23 +02:00 committed by Qt Cherry-pick Bot
parent 5fc66f68da
commit 3cdc9084ba

View File

@ -336,8 +336,11 @@ public:
template<typename Functor>
QMacNotificationObserver(NSObject *object, NSNotificationName name, Functor callback) {
observer = [[NSNotificationCenter defaultCenter] addObserverForName:name
object:object queue:nil usingBlock:^(NSNotification *) {
callback();
object:object queue:nil usingBlock:^(NSNotification *notification) {
if constexpr (std::is_invocable_v<Functor, NSNotification *>)
callback(notification);
else
callback();
}
];
}