Skip to content

Commit c51a37c

Browse files
committed
Do not remove tray icon when WM_OVPN_STOPALL is processed
- commit f8a243f 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 <[email protected]>
1 parent 4803c7a commit c51a37c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

main.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,14 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
353353

354354

355355
static void
356-
StopAllOpenVPN()
356+
StopAllOpenVPN(bool exiting)
357357
{
358358
int i;
359359

360-
RemoveTrayIcon();
360+
if (exiting)
361+
{
362+
RemoveTrayIcon();
363+
}
361364

362365
/* Stop all connections started by us -- we leave persistent ones
363366
* at their current state. Use the disconnect menu to put them into
@@ -451,7 +454,9 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data)
451454
ShowWindow(c->hwndStatus, SW_SHOW);
452455
}
453456
else if(copy_data->dwData == WM_OVPN_STOPALL)
454-
StopAllOpenVPN();
457+
{
458+
StopAllOpenVPN(false);
459+
}
455460
else if(copy_data->dwData == WM_OVPN_SILENT && str)
456461
{
457462
if (_wtoi(str) == 0)
@@ -680,7 +685,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
680685

681686
case WM_DESTROY:
682687
WTSUnRegisterSessionNotification(hwnd);
683-
StopAllOpenVPN();
688+
StopAllOpenVPN(true);
684689
OnDestroyTray(); /* Remove Tray Icon and destroy menus */
685690
PostQuitMessage (0); /* Send a WM_QUIT to the message queue */
686691
break;
@@ -690,7 +695,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
690695

691696
case WM_ENDSESSION:
692697
SaveAutoRestartList();
693-
StopAllOpenVPN();
698+
StopAllOpenVPN(true);
694699
OnDestroyTray();
695700
break;
696701

@@ -980,7 +985,7 @@ ErrorExit(int exit_code, const wchar_t *msg)
980985
MB_OK | MB_SETFOREGROUND | MB_ICONERROR | MBOX_RTL_FLAGS, GetGUILanguage());
981986
if (o.hWnd)
982987
{
983-
StopAllOpenVPN();
988+
StopAllOpenVPN(true);
984989
PostQuitMessage(exit_code);
985990
}
986991
else

0 commit comments

Comments
 (0)