From a46ecf9bff4b6619cde53d09de12b6145106618d Mon Sep 17 00:00:00 2001 From: Albert S Date: Sat, 6 Jun 2020 23:18:33 +0200 Subject: [PATCH] gui: disable searchbar when search is running avoids waiting in the gui thread. does not try to cancel the QFuture that actually cannot be cancelled anyway. sidesteps a strange bug which rethrows already caught exception. --- gui/mainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e6cc510..049f3fd 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -49,6 +49,7 @@ void MainWindow::connectSignals() { try { + this->ui->txtSearch->setEnabled(true); auto results = searchWatcher.future().result(); handleSearchResults(results); } @@ -169,8 +170,7 @@ void MainWindow::lineEditReturnPressed() } // TODO: validate q; ui->lblSearchResults->setText("Searching..."); - searchWatcher.cancel(); - searchWatcher.waitForFinished(); + this->ui->txtSearch->setEnabled(false); QFuture> searchFuture = QtConcurrent::run( [&, q]() {