From c51a37c2ffcff4fe25040753a95a1cb934cbb2b9 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Thu, 9 Mar 2023 22:26:02 -0500 Subject: [PATCH] Do not remove tray icon when WM_OVPN_STOPALL is processed - commit f8a243fbe introduced removing the tray icon during the wait for exit to avoid further user interaction. This is done in StopAllOpenVPN(). However, this function is also reused for processing WM_OVPN_STOPALL message received from a second instance via --comamnd disconnect_all. In this case the tray icon should not be removed as we are not exiting. Fixes issue #607 Signed-off-by: Selva Nair --- main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 5263e087..ddb1dfef 100644 --- a/main.c +++ b/main.c @@ -353,11 +353,14 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, static void -StopAllOpenVPN() +StopAllOpenVPN(bool exiting) { int i; - RemoveTrayIcon(); + if (exiting) + { + RemoveTrayIcon(); + } /* Stop all connections started by us -- we leave persistent ones * at their current state. Use the disconnect menu to put them into @@ -451,7 +454,9 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data) ShowWindow(c->hwndStatus, SW_SHOW); } else if(copy_data->dwData == WM_OVPN_STOPALL) - StopAllOpenVPN(); + { + StopAllOpenVPN(false); + } else if(copy_data->dwData == WM_OVPN_SILENT && str) { if (_wtoi(str) == 0) @@ -680,7 +685,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_DESTROY: WTSUnRegisterSessionNotification(hwnd); - StopAllOpenVPN(); + StopAllOpenVPN(true); OnDestroyTray(); /* Remove Tray Icon and destroy menus */ PostQuitMessage (0); /* Send a WM_QUIT to the message queue */ break; @@ -690,7 +695,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_ENDSESSION: SaveAutoRestartList(); - StopAllOpenVPN(); + StopAllOpenVPN(true); OnDestroyTray(); break; @@ -980,7 +985,7 @@ ErrorExit(int exit_code, const wchar_t *msg) MB_OK | MB_SETFOREGROUND | MB_ICONERROR | MBOX_RTL_FLAGS, GetGUILanguage()); if (o.hWnd) { - StopAllOpenVPN(); + StopAllOpenVPN(true); PostQuitMessage(exit_code); } else