From 84fa2420dd1ef644ed41ab4d46aa62e02365a5ba Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 28 Jul 2016 19:49:02 +0200 Subject: [PATCH] Fix crash when logging out from ICS The patch that sent "logout" to the ICS on a fatal error backfired when the 'fatal error' was a disconnect, and caused a crash on Mac. We now suppress sending of this "logout" command in the disconnect case, communicated in a kludgy way (by requesting exit status 6666). --- backend.c | 2 +- dialogs.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index b288d6b..776f751 100644 --- a/backend.c +++ b/backend.c @@ -4301,7 +4301,7 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int } else if (count == 0) { RemoveInputSource(isr); - DisplayFatalError(_("Connection closed by ICS"), 0, 0); + DisplayFatalError(_("Connection closed by ICS"), 0, 6666); } else { DisplayFatalError(_("Error reading from ICS"), error, 1); } diff --git a/dialogs.c b/dialogs.c index d0c372a..af11b49 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2523,12 +2523,12 @@ DisplayMoveError (String message) void DisplayFatalError (String message, int error, int status) { - char buf[MSG_SIZ]; + char buf[MSG_SIZ], logout = appData.icsActive; if(status == 666) { // ignore this error when ICS Console window is up if(shellUp[ChatDlg]) return; status = 0; - } + } else if(status == 6666) status = logout = 0; // 6666 = kludge that indicates ICS connection already closed errorExitStatus = status; if (error == 0) { @@ -2541,7 +2541,7 @@ DisplayFatalError (String message, int error, int status) } if(mainOptions[W_BOARD].handle) { if (appData.popupExitMessage) { - if(appData.icsActive) SendToICS("logout\n"); // [HGM] make sure no new games will be started + if(logout) SendToICS("logout\n"); // [HGM] make sure no new games will be started ErrorPopUp(status ? _("Fatal Error") : _("Exiting"), message, TRUE); } else { ExitEvent(status); -- 1.7.0.4