mirror of https://github.com/OpenVPN/openvpn-gui
On WM_CLOSE do not ask user confirmation
- WM_CLOSE is sent if the process is terminated from task manager or by taskkill etc. Waiting for user confirmation in such cases leads to abnormal termination of process leaving behind openvpn.exe, active connections state not saved to the registry etc. CloseApplication() now gets a second argument ask_user. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/608/head
parent
acb5b8f9c8
commit
4085f259a6
12
main.c
12
main.c
|
@ -63,7 +63,7 @@
|
||||||
/* Declare Windows procedure */
|
/* Declare Windows procedure */
|
||||||
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
||||||
static void ShowSettingsDialog();
|
static void ShowSettingsDialog();
|
||||||
void CloseApplication(HWND hwnd);
|
void CloseApplication(HWND hwnd, BOOL ask_user);
|
||||||
void ImportConfigFileFromDisk();
|
void ImportConfigFileFromDisk();
|
||||||
void ImportConfigFromAS();
|
void ImportConfigFromAS();
|
||||||
static void SaveAutoRestartList();
|
static void SaveAutoRestartList();
|
||||||
|
@ -456,7 +456,7 @@ HandleCopyDataMessage(const COPYDATASTRUCT *copy_data)
|
||||||
}
|
}
|
||||||
else if(copy_data->dwData == WM_OVPN_EXIT)
|
else if(copy_data->dwData == WM_OVPN_EXIT)
|
||||||
{
|
{
|
||||||
CloseApplication(o.hWnd);
|
CloseApplication(o.hWnd, true);
|
||||||
}
|
}
|
||||||
else if(copy_data->dwData == WM_OVPN_IMPORT && str)
|
else if(copy_data->dwData == WM_OVPN_IMPORT && str)
|
||||||
{
|
{
|
||||||
|
@ -628,7 +628,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
ShowSettingsDialog();
|
ShowSettingsDialog();
|
||||||
}
|
}
|
||||||
else if (LOWORD(wParam) == IDM_CLOSE) {
|
else if (LOWORD(wParam) == IDM_CLOSE) {
|
||||||
CloseApplication(hwnd);
|
CloseApplication(hwnd, true);
|
||||||
}
|
}
|
||||||
/* rest of the handlers require a connection id */
|
/* rest of the handlers require a connection id */
|
||||||
else {
|
else {
|
||||||
|
@ -670,7 +670,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
CloseApplication(hwnd);
|
CloseApplication(hwnd, false); /* do not wait for user confirmation */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
|
@ -844,10 +844,10 @@ ShowSettingsDialog()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CloseApplication(HWND hwnd)
|
CloseApplication(HWND hwnd, BOOL ask_user)
|
||||||
{
|
{
|
||||||
/* Show a message if any non-persistent connections are active */
|
/* Show a message if any non-persistent connections are active */
|
||||||
for (connection_t *c = o.chead; c; c = c->next)
|
for (connection_t *c = o.chead; c && ask_user; c = c->next)
|
||||||
{
|
{
|
||||||
if (c->state == disconnected
|
if (c->state == disconnected
|
||||||
|| c->flags & FLAG_DAEMON_PERSISTENT)
|
|| c->flags & FLAG_DAEMON_PERSISTENT)
|
||||||
|
|
Loading…
Reference in New Issue