summaryrefslogtreecommitdiff
path: root/plugins/KeyboardNotify/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-04 20:42:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-04 20:42:25 +0300
commit68c7bf3b55ca132143686ab433659c3b828760aa (patch)
tree5e2b5f5bc674f05a4c351a8f4f0ea6b6e596ca16 /plugins/KeyboardNotify/src
parentef6ef30fac86de58bfd7d52b1d8a213b8d955d5d (diff)
attempt to fix some problems on exit
Diffstat (limited to 'plugins/KeyboardNotify/src')
-rw-r--r--plugins/KeyboardNotify/src/main.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp
index 6bab75efb5..321aa68a9e 100644
--- a/plugins/KeyboardNotify/src/main.cpp
+++ b/plugins/KeyboardNotify/src/main.cpp
@@ -266,8 +266,9 @@ static void __cdecl FlashThreadFunction(void*)
BYTE data, unchangedLeds;
Thread_SetName("KeyboardNotify: FlashThreadFunction");
+ MThreadHandle threadLock(hThread);
- while (TRUE) {
+ while (true) {
unchangedLeds = (BYTE)(LedState(VK_PAUSE) * !bFlashLed[2] + ((LedState(VK_NUMLOCK) * !bFlashLed[0]) << 1) + ((LedState(VK_CAPITAL) * !bFlashLed[1]) << 2));
GetAsyncKeyState(VK_PAUSE); // empty Pause/Break's keystroke buffer
@@ -902,7 +903,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
mir_snwprintf(eventName, L"%s/ExitEvent", eventPrefix);
hExitEvent = CreateEvent(nullptr, FALSE, FALSE, eventName);
- hThread = mir_forkthread(FlashThreadFunction);
+ mir_forkthread(FlashThreadFunction);
CreateServiceFunction(MS_KBDNOTIFY_ENABLE, EnableService);
CreateServiceFunction(MS_KBDNOTIFY_DISABLE, DisableService);
@@ -934,7 +935,8 @@ int CMPlugin::Unload()
UnhookWindowsHooks();
// Wait for thread to exit
- WaitForSingleObject(hThread, INFINITE);
+ if (hThread)
+ WaitForSingleObject(hThread, INFINITE);
if (hExitEvent)
CloseHandle(hExitEvent);