summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-11-08 13:48:02 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-11-09 16:13:05 +0200
commit7936c138fe997b10c8241f1ad298971a1b271ad4 (patch)
treed1d58f7557b779472c2cb3c3edc3ae9a65613fdf
parentca73bbc9bea544c7e437cc419f2566ef7659f5b0 (diff)
downloadqtlocation-mapboxgl-7936c138fe997b10c8241f1ad298971a1b271ad4.tar.gz
[Qt] Call QSqlQuery::finish() when inactive
-rw-r--r--platform/qt/src/sqlite3.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp
index f5e5f7a690..1d18946364 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<uint8_t>& 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<int64_t>();
+ impl->changes = impl->query.numRowsAffected();
+ } else {
+ checkQueryError(impl->query);
+ }
}
- if (!impl->query.exec()) {
- checkQueryError(impl->query);
- }
-
- impl->lastInsertRowId = impl->query.lastInsertId().value<int64_t>();
- impl->changes = impl->query.numRowsAffected();
+ const bool hasNext = impl->query.next();
+ if (!hasNext) impl->query.finish();
- return impl->query.next();
+ return hasNext;
}
template bool Statement::get(int);