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.
This commit is contained in:
Albert S. 2020-06-06 23:18:33 +02:00
rodzic 072996e0d3
commit 1e10d12f34

Wyświetl plik

@ -49,14 +49,15 @@ void MainWindow::connectSignals()
connect(&searchWatcher, &QFutureWatcher<SearchResult>::finished, this, [&]{
try
{
this->ui->txtSearch->setEnabled(true);
auto results = searchWatcher.future().result();
handleSearchResults(results);
}
catch(QSSGeneralException &e)
{
handleSearchError(e.message);
}
});
connect(&pdfWorkerWatcher, &QFutureWatcher<PdfPreview>::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<QVector<SearchResult>> searchFuture = QtConcurrent::run([&, q]() {
SqliteSearch searcher(db);
this->currentQuery = QSSQuery::build(q);