]> granicus.if.org Git - nethack/commitdiff
different fix for #H4332 - Qt crashes upon quit
authorPatR <rankin@nethack.org>
Sat, 14 May 2016 09:13:07 +0000 (02:13 -0700)
committerPatR <rankin@nethack.org>
Sat, 14 May 2016 09:13:07 +0000 (02:13 -0700)
Quiting without ever examining inventory caused the Qt interface
to issue an impossible(), then crash due to deferencing a Null
pointer.  The prior fix was to suppress the validation code that
was crashing.  This changes things so that the inventory window
always gets at least one use, allowing the Qt validation code to
succeed.  tty and X11 are ok with it; win32 needs to be verified.

src/allmain.c
win/Qt/qt_win.cpp

index 4aef642c54168a7463df27dac07efbdedd5941de..7d7ff03c6e1b9bc5846f8f7b3c208d41e3a6d37f 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 allmain.c       $NHDT-Date: 1451955079 2016/01/05 00:51:19 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.70 $ */
+/* NetHack 3.6 allmain.c       $NHDT-Date: 1463217182 2016/05/14 09:13:02 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.72 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -506,6 +506,9 @@ display_gamewindows()
 #endif
     WIN_MAP = create_nhwindow(NHW_MAP);
     WIN_INVEN = create_nhwindow(NHW_MENU);
+    /* in case of early quit where WIN_INVEN could be destroyed before
+       ever having been used, use it here to pacify the Qt interface */
+    start_menu(WIN_INVEN), end_menu(WIN_INVEN, (char *) 0);
 
 #ifdef MAC
     /* This _is_ the right place for this - maybe we will
index 8350c8ca9a27a2dbfa23021dc1df694d66ef3cde..db995f7ea36b352888aa005158190fcf15a58f22 100644 (file)
@@ -4401,12 +4401,11 @@ void NetHackQtMenuOrTextWindow::Display(bool block)
 
 bool NetHackQtMenuOrTextWindow::Destroy()
 {
-    bool res;
+    bool res = FALSE;
 
-    if (!actual) {
-        /* impossible("Destroy called before we know if Menu or Text"); */
-        res = FALSE; // early Destroy is not impossible
-    } else
+    if (!actual)
+        impossible("Destroy called before we know if Menu or Text");
+    else
         res = actual->Destroy();
 
     return res;