summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-07-26 15:09:58 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-07-26 15:39:03 +0300
commit55faa23d2e903cf7527ff58da152cbbc29bf260b (patch)
tree3d44a33585c1c3b7543f9ed078dad2b6f381cc8a /platform/qt
parent565dfc91833fbac4d40ac13293225720919a0773 (diff)
downloadqtlocation-mapboxgl-55faa23d2e903cf7527ff58da152cbbc29bf260b.tar.gz
[Qt] Fix database timeout not being set correctly
It was overflowing due to long to int conversion inside Qt and never being effectively set because Qt was silently ignoring the conversion error and discarding the new value. Fixes #9108.
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/src/sqlite3.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/qt/src/sqlite3.cpp b/platform/qt/src/sqlite3.cpp
index 6ed55c541f..0cd78d85ce 100644
--- a/platform/qt/src/sqlite3.cpp
+++ b/platform/qt/src/sqlite3.cpp
@@ -11,6 +11,7 @@
#include <cstring>
#include <cstdio>
#include <chrono>
+#include <limits>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/logging.hpp>
@@ -141,7 +142,11 @@ Database::~Database() {
void Database::setBusyTimeout(std::chrono::milliseconds timeout) {
assert(impl);
- std::string timeoutStr = mbgl::util::toString(timeout.count());
+
+ // std::chrono::milliseconds.count() is a long and Qt will cast
+ // internally to int, so we need to make sure the limits apply.
+ std::string timeoutStr = mbgl::util::toString(timeout.count() & INT_MAX);
+
QString connectOptions = impl->db->connectOptions();
if (connectOptions.isEmpty()) {
if (!connectOptions.isEmpty()) connectOptions.append(';');