mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-28 16:07:02 +01:00
[KBM] Fix for handle leak
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,14 @@ public:
|
||||
// Constructor
|
||||
KeyboardManager();
|
||||
|
||||
~KeyboardManager()
|
||||
{
|
||||
if (editorIsRunningEvent)
|
||||
{
|
||||
CloseHandle(editorIsRunningEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void StartLowlevelKeyboardHook();
|
||||
void StopLowlevelKeyboardHook();
|
||||
|
||||
@@ -43,6 +51,8 @@ private:
|
||||
// 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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user