]> granicus.if.org Git - nethack/commitdiff
hangup vs msghistory (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 6 Apr 2009 00:46:43 +0000 (00:46 +0000)
committernethack.rankin <nethack.rankin>
Mon, 6 Apr 2009 00:46:43 +0000 (00:46 +0000)
[First of three message history patches.]

     The post-3.4.3 hangup changes broke the post-3.4.3 message history
save/restore for tty (and maybe Win32, if it supports hangup handling;
other interfaces haven't implemented message history save/restore yet)
during hangup saves by preventing interface-specific getmsghistory() from
being called.  Relatively benign; hangup save just behaved as if message
history was empty, so restore had no old messages to put back.  Naturally
post-hangup restore is when players would be most interested in reviewing
the previous session's messages, so benign failure isn't acceptable.  Fix
is to leave getmsghistory() intact when replacing windowprocs with the
I/O-free routines.  [I can't trigger real hangups for testing, but can
call hangup() from within the debugger to force an approximation of one.]

src/windows.c

index 7a2d6ad8945fec9190d45cb710d916a5bd6caceb..4b490d22de8fcbb242489179f4c0b04174607261 100644 (file)
@@ -319,13 +319,24 @@ static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0;
 void
 nhwindows_hangup()
 {
+    char *FDECL((*previnterface_getmsghistory), (BOOLEAN_P)) = 0;
+
     /* don't call exit_nhwindows() directly here; if a hangup occurs
        while interface code is executing, exit_nhwindows could knock
        the interface's active data structures out from under itself */
     if (iflags.window_inited &&
            windowprocs.win_exit_nhwindows != hup_exit_nhwindows)
        previnterface_exit_nhwindows = windowprocs.win_exit_nhwindows;
+
+    /* also, we have to leave the old interface's getmsghistory()
+       in place because it will be called while saving the game */
+    if (windowprocs.win_getmsghistory != hup_procs.win_getmsghistory)
+       previnterface_getmsghistory = windowprocs.win_getmsghistory;
+
     windowprocs = hup_procs;
+
+    if (previnterface_getmsghistory)
+       windowprocs.win_getmsghistory = previnterface_getmsghistory;
 }
 
 static void