summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2017-01-11 18:09:23 -0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-01-23 19:06:53 +0200
commit1065917e59c0238b63dccf8cba46415fffe8da57 (patch)
treeed8e481f6d90fc84bdc713d17fd6fda3b69bb5f4
parent88b7fc3929acbe119b3dbfa2a9f6dbd04b338ebe (diff)
downloadqtlocation-mapboxgl-1065917e59c0238b63dccf8cba46415fffe8da57.tar.gz
[Qt] Save a copy when using binary data if possible
-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 57725b8233..b339cb14fa 100644
--- a/platform/qt/src/sqlite3.cpp
+++ b/platform/qt/src/sqlite3.cpp
@@ -233,7 +233,7 @@ void Statement::bind(int offset, optional<mbgl::Timestamp> value) {
}
}
-void Statement::bind(int offset, const char* value, std::size_t length, bool /* retain */) {
+void Statement::bind(int offset, const char* value, std::size_t length, bool retain) {
assert(impl);
if (length > std::numeric_limits<int>::max()) {
// Kept for consistence with the default implementation.
@@ -241,22 +241,23 @@ void Statement::bind(int offset, const char* value, std::size_t length, bool /*
}
// Field numbering starts at 0.
- impl->query.bindValue(offset - 1, QString::fromLatin1(value, length), QSql::In);
+ impl->query.bindValue(offset - 1, retain ? QByteArray(value, length) :
+ QByteArray::fromRawData(value, length), QSql::In);
+
checkQueryError(impl->query);
}
-void Statement::bind(int offset, const std::string& value, bool /* retain */) {
- // Field numbering starts at 0.
- impl->query.bindValue(offset - 1, QString::fromStdString(value), QSql::In);
- checkQueryError(impl->query);
+void Statement::bind(int offset, const std::string& value, bool retain) {
+ bind(offset, value.data(), value.size(), retain);
}
-void Statement::bindBlob(int offset, const void* value, std::size_t length, bool /* retain */) {
- assert(impl);
+void Statement::bindBlob(int offset, const void* value_, std::size_t length, bool retain) {
const char* value = reinterpret_cast<const char*>(value_);
// Field numbering starts at 0.
- impl->query.bindValue(offset - 1, QByteArray(reinterpret_cast<const char*>(value), length), QSql::In | QSql::Binary);
+ impl->query.bindValue(offset - 1, retain ? QByteArray(value, length) :
+ QByteArray::fromRawData(value, length), QSql::In | QSql::Binary);
+
checkQueryError(impl->query);
}