Fix closing databases

This commit is contained in:
Jonas Kvinge
2019-07-25 17:56:28 +02:00
parent 41484f8673
commit 81caec99b7
10 changed files with 82 additions and 63 deletions

View File

@@ -754,11 +754,10 @@ CollectionModel::QueryResult CollectionModel::RunQuery(CollectionItem *parent) {
// Execute the query
QMutexLocker l(backend_->db()->Mutex());
if (!backend_->ExecQuery(&q)) return result;
while (q.Next()) {
result.rows << SqlRow(q);
if (backend_->ExecQuery(&q)) {
while (q.Next()) {
result.rows << SqlRow(q);
}
}
if (QThread::currentThread() != thread() && QThread::currentThread() != backend_->thread()) {
@@ -811,6 +810,10 @@ void CollectionModel::ResetAsync() {
void CollectionModel::ResetAsyncQueryFinished(QFuture<CollectionModel::QueryResult> future) {
if (QThread::currentThread() != thread() && QThread::currentThread() != backend_->thread()) {
backend_->Close();
}
const struct QueryResult result = future.result();
BeginReset();