diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.cpp b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.cpp index 6b94efe4c4eb..1018dc4c6daf 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.cpp +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.cpp @@ -51,6 +51,7 @@ KeyboardManager::KeyboardManager() loadingSettings = false; }; + editorIsRunningEvent = CreateEvent(nullptr, true, false, KeyboardManagerConstants::EditorWindowEventName.c_str()); settingsEventWaiter = EventWaiter(KeyboardManagerConstants::SettingsEventName, changeSettingsCallback); } @@ -127,8 +128,7 @@ intptr_t KeyboardManager::HandleKeyboardHookEvent(LowlevelKeyboardEvent* data) n } // Suspend remapping if remap key/shortcut window is opened - auto h = CreateEvent(nullptr, true, false, KeyboardManagerConstants::EditorWindowEventName.c_str()); - if (h != nullptr && WaitForSingleObject(h, 0) == WAIT_OBJECT_0) + if (editorIsRunningEvent != nullptr && WaitForSingleObject(editorIsRunningEvent, 0) == WAIT_OBJECT_0) { return 0; } diff --git a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h index f5cca2250877..d9b840b3952f 100644 --- a/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h +++ b/src/modules/keyboardmanager/KeyboardManagerEngineLibrary/KeyboardManager.h @@ -9,6 +9,14 @@ class KeyboardManager // Constructor KeyboardManager(); + ~KeyboardManager() + { + if (editorIsRunningEvent) + { + CloseHandle(editorIsRunningEvent); + } + } + void StartLowlevelKeyboardHook(); void StopLowlevelKeyboardHook(); @@ -43,6 +51,8 @@ class KeyboardManager // Load settings from the file. void LoadSettings(); + HANDLE editorIsRunningEvent = nullptr; + // Function called by the hook procedure to handle the events. This is the starting point function for remapping intptr_t HandleKeyboardHookEvent(LowlevelKeyboardEvent* data) noexcept; };