From 37299c2d2e46258b3a41fcae58d2403e4d224f57 Mon Sep 17 00:00:00 2001 From: Rajveer Aujla Date: Wed, 25 Jan 2023 00:14:29 +0000 Subject: [PATCH] [BUGFIX] Fix macOS not properly skipping hotkey registration/unregistration --- src/lib/platform/OSXScreen.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 73bbac9b..839b8876 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -336,7 +336,7 @@ OSXScreen::registerHotKey(KeyID key, KeyModifierMask mask, bool registerGlobalHo // if this hot key has modifiers only then we'll handle it specially EventHotKeyRef ref = NULL; - bool okay; + bool okay = true; if (key == kKeyNone) { if (m_modifierHotKeys.count(mask) > 0) { // already registered @@ -381,9 +381,11 @@ OSXScreen::unregisterHotKey(UInt32 id, bool unregisterGlobalHotkey) } // unregister with OS - bool okay; - if (unregisterGlobalHotkey && i->second.getRef() != NULL) { - okay = (UnregisterEventHotKey(i->second.getRef()) == noErr); + bool okay = true; + if (i->second.getRef() != NULL) { + if (unregisterGlobalHotkey) { + okay = (UnregisterEventHotKey(i->second.getRef()) == noErr); + } } else { okay = false;