From ef9125ba672acd60fa29273d4b953761ad47714b Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 6 Mar 2019 10:36:13 +0100 Subject: [PATCH] Windows: try to stop indexing when receiving a powerbroadcast message --- src/common/rclinit.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common/rclinit.cpp b/src/common/rclinit.cpp index 7c434e21..060360ca 100644 --- a/src/common/rclinit.cpp +++ b/src/common/rclinit.cpp @@ -165,20 +165,34 @@ LRESULT CALLBACK MainWndProc(HWND hwnd , UINT msg , WPARAM wParam, LPARAM lParam) { switch (msg) { + case WM_POWERBROADCAST: + { + LOGDEB("MainWndProc: got powerbroadcast message\n"); + // We always try to end an indexing operation, independantly + // of the kind of event. Mounted volumes may have changed + // etc. Using SIGTERM just to have something different from + // the other messages + if (l_sigcleanup) { + l_sigcleanup(SIGTERM); + } + } + break; case WM_QUERYENDSESSION: case WM_ENDSESSION: case WM_DESTROY: case WM_CLOSE: { - l_sigcleanup(SIGINT); + if (l_sigcleanup) { + l_sigcleanup(SIGINT); + } LOGDEB("MainWndProc: got end message, waiting for work finished\n" ); DWORD res = WaitForSingleObject(eWorkFinished, INFINITE); if (res != WAIT_OBJECT_0) { LOGERR("MainWndProc: exit ack wait failed\n" ); } LOGDEB("MainWindowProc: got exit ready event, exiting\n" ); - return TRUE; } + break; default: return DefWindowProc(hwnd, msg, wParam, lParam); }