1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-16 10:37:38 -05:00

Prevent network errors from summarily closing the window when CoE is off

[originally from svn r613]
This commit is contained in:
Simon Tatham
2000-09-22 11:04:57 +00:00
parent 985207d4a9
commit e5ef37f3f5
7 changed files with 148 additions and 48 deletions

View File

@ -520,6 +520,25 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
return msg.wParam;
}
/*
* Print a message box and close the connection.
*/
void connection_fatal(char *fmt, ...) {
va_list ap;
char stuff[200];
va_start(ap, fmt);
vsprintf(stuff, fmt, ap);
va_end(ap);
MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
if (cfg.close_on_exit)
PostQuitMessage(1);
else {
session_closed = TRUE;
SetWindowText (hwnd, "PuTTY (inactive)");
}
}
/*
* Actually do the job requested by a WM_NETEVENT
*/
@ -546,10 +565,9 @@ static void enact_pending_netevent(void) {
sprintf(buf, "Unexpected network error %d", -i);
break;
}
MessageBox(hwnd, buf, "PuTTY Fatal Error",
MB_ICONERROR | MB_OK);
PostQuitMessage(1);
} else if (i == 0) {
connection_fatal(buf);
}
if (i <= 0) {
if (cfg.close_on_exit)
PostQuitMessage(0);
else {