mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
[KBM] Fix for handle leak (#11182)
This commit is contained in:
parent
489ff37bf4
commit
617b7adb09
@ -50,6 +50,7 @@ KeyboardManager::KeyboardManager()
|
||||
loadingSettings = false;
|
||||
};
|
||||
|
||||
editorIsRunningEvent = CreateEvent(nullptr, true, false, KeyboardManagerConstants::EditorWindowEventName.c_str());
|
||||
settingsEventWaiter = EventWaiter(KeyboardManagerConstants::SettingsEventName, changeSettingsCallback);
|
||||
}
|
||||
|
||||
@ -126,8 +127,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;
|
||||
}
|
||||
|
@ -10,6 +10,14 @@ public:
|
||||
// Constructor
|
||||
KeyboardManager();
|
||||
|
||||
~KeyboardManager()
|
||||
{
|
||||
if (editorIsRunningEvent)
|
||||
{
|
||||
CloseHandle(editorIsRunningEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void StartLowlevelKeyboardHook();
|
||||
void StopLowlevelKeyboardHook();
|
||||
|
||||
@ -38,6 +46,8 @@ private:
|
||||
|
||||
std::atomic_bool loadingSettings = false;
|
||||
|
||||
HANDLE editorIsRunningEvent = nullptr;
|
||||
|
||||
// Hook procedure definition
|
||||
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user