From: PatR Date: Thu, 14 Jan 2021 23:10:41 +0000 (-0800) Subject: fix github issue #400 - Qt text windows hanging X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=648162b53635591ca6f2db2ba2217f4a083568bb;p=nethack fix github issue #400 - Qt text windows hanging Text windows only accept a few keys (, , ':', now ) 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 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 once, or or twice, or else search again and pick [done] on the search popup and then or once, to dismiss a text window via keyboard. (Prior to this, typing or searching again and picking [done] followed by were the only ways.) Also, searching for an empty string will now be treated as if [done] had been picked. Fixes #400 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 63fae5848..e19dddaf2 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 but 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 , the text diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index b86e7484f..16448e891 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -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); } }