]> granicus.if.org Git - nethack/commitdiff
fix github issue #400 - Qt text windows hanging
authorPatR <rankin@nethack.org>
Thu, 14 Jan 2021 23:10:41 +0000 (15:10 -0800)
committerPatR <rankin@nethack.org>
Thu, 14 Jan 2021 23:10:41 +0000 (15:10 -0800)
Text windows only accept a few keys (<escape>, <return>, ':', now
<space>) and if they got other keys they passed those up the call
chain, arriving at the map where they were treated as commands
and were executed while the text window was still displayed.  The
cited example was ',' for pickup while the "things that are here"
popup was shown.  The 'foreign' key's command might be executed
successfully but the undismissed popup could become hung.

This fixes that ('foreign' keys will be ignored).  It also lets
<space> be used to dismiss text windows.

Slightly better but far from perfect:  if you perform a search,
then after it runs you need to type <escape> once, or <return>
or <space> twice, or else search again and pick [done] on the
search popup and then <return> or <space> once, to dismiss a
text window via keyboard.  (Prior to this, typing <escape> or
searching again and picking [done] followed by <return> were the
only ways.)  Also, searching for an empty string will now be
treated as if [done] had been picked.

Fixes #400

doc/fixes37.0
win/Qt/qt_menu.cpp

index 63fae5848617a919a78391ad8a6f3ba3075455ef..e19dddaf2c3a2ca6a604675dc48d1d352efa733c 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.428 $ $NHDT-Date: 1610587460 2021/01/14 01:24:20 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.429 $ $NHDT-Date: 1610665839 2021/01/14 23:10:39 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -596,6 +596,10 @@ Qt: there was no way to enter extended command "#version" by typing; command
        name matching was waiting to disambiguate it from "#versionshort"
        and the only way to that was to type #version<return> but <return>
        explicitly triggered rejection, cancelling '#' processing
+Qt: while a text window was shown (such as the "things that are here" popup
+       when stepping on items), typing commands had the input passed on to
+       the map and then executed; sometimes that caused the not-yet-dismissed
+       text window to hang
 Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
        for instance), clicking on [Search], entering a search target in the
        resulting popup and clicking on [Okay] or typing <return>, the text
index b86e7484fbc62ca2aa0e1fbd85278d469ef4615c..16448e891f32b52e127caefbdd1be6e697cd5087 100644 (file)
@@ -1175,7 +1175,7 @@ void NetHackQtTextWindow::Search()
         this->raise();
     }
 
-    if (get_a_line) {
+    if (get_a_line && target[0]) {
         int linecount = lines->count();
         int current = lines->currentRow();
         if (current == -1)
@@ -1215,13 +1215,16 @@ void NetHackQtTextWindow::keyPressEvent(QKeyEvent *key_event)
     if (key == MENU_SEARCH) {
         if (!use_rip)
             Search();
-    } else if (key == '\n' || key == '\r') {
+    } else if (key == '\n' || key == '\r' || key == ' ') {
         if (!textsearching)
             accept();
+        else
+            textsearching = FALSE;
     } else if (key == '\033') {
         reject();
     } else {
-        QDialog::keyPressEvent(key_event);
+        // ignore the current key instead of passing it along
+        //- QDialog::keyPressEvent(key_event);
     }
 }