From 1e10d12f34b62142b60d9a4c1d9193ac2a857ed7 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0888cd4..073ee66 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -49,14 +49,15 @@ void MainWindow::connectSignals() connect(&searchWatcher, &QFutureWatcher::finished, this, [&]{ try { + this->ui->txtSearch->setEnabled(true); auto results = searchWatcher.future().result(); handleSearchResults(results); + } catch(QSSGeneralException &e) { handleSearchError(e.message); } - }); connect(&pdfWorkerWatcher, &QFutureWatcher::resultReadyAt, this, [&](int index) { @@ -165,8 +166,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]() { SqliteSearch searcher(db); this->currentQuery = QSSQuery::build(q);