From: PatR Date: Sat, 12 Dec 2020 02:11:27 +0000 (-0800) Subject: Qt text search crash fix X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b709fcb550dd6d8dcf6a3eaeae866d564539914;p=nethack Qt text search crash fix About 5 weeks ago, commit e4106bb1613da808ae87780dfeedb4c80e6afc2a changed Qt's searching in text windows to be able to find a match on the very first line. It assumed that the first line would be the current line except when repeating the same search after a match. But after a failed search the current line index is -1 and starting a new search would crash trying to look that line up. --- diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index ab8b59ea7..1a549a8e0 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -1192,6 +1192,8 @@ void NetHackQtTextWindow::Search() if (get_a_line) { int linecount = lines->count(); int current = lines->currentRow(); + if (current == -1) + current = 0; // when no row is highlighted (selected), start the search // on the current row, otherwise start on the row after it // [normally means that the very first row is a candidate