From b4429a2c9b6ac37b263c16c3a7e6d0314031b60f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Apr 2021 20:11:05 +0300 Subject: more logs for hangout in KeyboardNotify --- plugins/KeyboardNotify/src/main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'plugins/KeyboardNotify/src') diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 02621dac3e..6b7da1d96e 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -297,8 +297,10 @@ static void __cdecl FlashThreadFunction(void*) ToggleKeyboardLights((BYTE)(data | unchangedLeds)); // Wait for exit event - if (WaitForSingleObject(hExitEvent, nWaitDelay) == WAIT_OBJECT_0) + if (WaitForSingleObject(hExitEvent, nWaitDelay) == WAIT_OBJECT_0) { + g_plugin.debugLogA("%s: got exit signal1", g_plugin.getModule()); return; + } } RestoreLEDState(); @@ -309,8 +311,10 @@ static void __cdecl FlashThreadFunction(void*) HANDLE Objects[2]; Objects[0] = hFlashEvent; Objects[1] = hExitEvent; - if (WaitForMultipleObjects(2, Objects, FALSE, INFINITE) == WAIT_OBJECT_0 + 1) + if (WaitForMultipleObjects(_countof(Objects), Objects, FALSE, INFINITE) != WAIT_OBJECT_0) { + g_plugin.debugLogA("%s: got exit signal2", g_plugin.getModule()); return; + } bEvent = TRUE; bReminderDisabled = TRUE; @@ -397,7 +401,6 @@ static int PluginMessageEventHook(WPARAM hContact, LPARAM hEvent) (einfo.eventType != EVENTTYPE_MESSAGE && einfo.eventType != EVENTTYPE_FILE && bFlashOnOther)) { if (contactCheckProtocol(einfo.szModule, hContact, einfo.eventType) && checkNotifyOptions() && checkStatus(einfo.szModule) && checkXstatus(einfo.szModule)) - SetEvent(hFlashEvent); } @@ -408,12 +411,10 @@ static int PluginMessageEventHook(WPARAM hContact, LPARAM hEvent) static int OnGcEvent(WPARAM, LPARAM lParam) { auto *gce = (GCEVENT *)lParam; - if (gce->iType == GC_EVENT_MESSAGE && bFlashOnGC) { - SESSION_INFO *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule); - if (si) + if (gce->iType == GC_EVENT_MESSAGE && bFlashOnGC) + if (SESSION_INFO *si = g_chatApi.SM_FindSession(gce->pszID.w, gce->pszModule)) if (contactCheckProtocol(si->pszModule, si->hContact, EVENTTYPE_MESSAGE) && checkNotifyOptions() && checkStatus(si->pszModule)) SetEvent(hFlashEvent); - } return 0; } @@ -882,6 +883,7 @@ static int OnMetaChanged(WPARAM wParam, LPARAM) static int OnPreshutdown(WPARAM, LPARAM) { + g_plugin.debugLogA("%s: got ME_SYSTEM_PRESHUTDOWN", g_plugin.getModule()); SetEvent(hExitEvent); return 0; } @@ -934,6 +936,11 @@ int CMPlugin::Unload() // Wait for thread to exit WaitForSingleObject(hThread, INFINITE); + if (hExitEvent) + CloseHandle(hExitEvent); + if (hFlashEvent) + CloseHandle(hFlashEvent); + RestoreLEDState(); CloseKeyboardDevice(); -- cgit v1.2.3