diff --git a/mainwindow.cpp b/mainwindow.cpp index a52515e..b89d96f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -148,18 +148,15 @@ void MainWindow::performQuery() queryCancel = std::move(connection->getCancel()); QString command = ui->queryEdit->toPlainText(); - queryFuture = std::async(std::launch::async, [this,command]()-> Pgsql::Result + std::thread([this,command]() { - auto res = connection->query(command); - QMetaObject::invokeMethod(this, "query_ready", Qt::QueuedConnection); // queues on main thread - return res; - }); - + auto res = std::make_shared(connection->query(command)); + QueueTask([this, res]() { query_ready(std::move(*res)); }); + }).detach(); } -void MainWindow::query_ready() +void MainWindow::query_ready(Pgsql::Result dbres) { - pg::Result dbres(std::move(queryFuture.get())); if (dbres) { auto st = dbres.resultStatus(); if (st == PGRES_TUPLES_OK) { diff --git a/mainwindow.h b/mainwindow.h index 134e4fb..6329310 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -60,7 +60,6 @@ private: std::unique_ptr explainModel; Pgsql::Canceller queryCancel; - std::future queryFuture; std::future> explainFuture; struct { @@ -74,6 +73,7 @@ private: // } queryState; void processNotice(const PGresult *result); + void query_ready(Pgsql::Result res); private slots: void startConnect(); @@ -81,7 +81,6 @@ private slots: void performQuery(); void performExplain(); void socket_activate_connect(int socket); - void query_ready(); void explain_ready(); void cancel_query(); void receiveNotice(Pgsql::ErrorDetails notice);