From 7936c138fe997b10c8241f1ad298971a1b271ad4 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 8 Nov 2017 13:48:02 +0200 Subject: [PATCH] [Qt] Call QSqlQuery::finish() when inactive --- platform/qt/src/sqlite3.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp index f5e5f7a69..1d1894636 100644 --- a/platform/qt/src/sqlite3.cpp +++ b/platform/qt/src/sqlite3.cpp @@ -305,18 +305,19 @@ void Statement::bindBlob(int offset, const std::vector& value, bool ret bool Statement::run() { assert(impl); - if (impl->query.isValid()) { - return impl->query.next(); + if (!impl->query.isValid()) { + if (impl->query.exec()) { + impl->lastInsertRowId = impl->query.lastInsertId().value(); + impl->changes = impl->query.numRowsAffected(); + } else { + checkQueryError(impl->query); + } } - if (!impl->query.exec()) { - checkQueryError(impl->query); - } + const bool hasNext = impl->query.next(); + if (!hasNext) impl->query.finish(); - impl->lastInsertRowId = impl->query.lastInsertId().value(); - impl->changes = impl->query.numRowsAffected(); - - return impl->query.next(); + return hasNext; } template bool Statement::get(int);