mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 02:39:22 +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;
|
loadingSettings = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
editorIsRunningEvent = CreateEvent(nullptr, true, false, KeyboardManagerConstants::EditorWindowEventName.c_str());
|
||||||
settingsEventWaiter = EventWaiter(KeyboardManagerConstants::SettingsEventName, changeSettingsCallback);
|
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
|
// Suspend remapping if remap key/shortcut window is opened
|
||||||
auto h = CreateEvent(nullptr, true, false, KeyboardManagerConstants::EditorWindowEventName.c_str());
|
if (editorIsRunningEvent != nullptr && WaitForSingleObject(editorIsRunningEvent, 0) == WAIT_OBJECT_0)
|
||||||
if (h != nullptr && WaitForSingleObject(h, 0) == WAIT_OBJECT_0)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,14 @@ public:
|
|||||||
// Constructor
|
// Constructor
|
||||||
KeyboardManager();
|
KeyboardManager();
|
||||||
|
|
||||||
|
~KeyboardManager()
|
||||||
|
{
|
||||||
|
if (editorIsRunningEvent)
|
||||||
|
{
|
||||||
|
CloseHandle(editorIsRunningEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StartLowlevelKeyboardHook();
|
void StartLowlevelKeyboardHook();
|
||||||
void StopLowlevelKeyboardHook();
|
void StopLowlevelKeyboardHook();
|
||||||
|
|
||||||
@ -38,6 +46,8 @@ private:
|
|||||||
|
|
||||||
std::atomic_bool loadingSettings = false;
|
std::atomic_bool loadingSettings = false;
|
||||||
|
|
||||||
|
HANDLE editorIsRunningEvent = nullptr;
|
||||||
|
|
||||||
// Hook procedure definition
|
// Hook procedure definition
|
||||||
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user