aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-28 09:04:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-28 09:04:50 +0200
commit09a77f00412d2547733a7a2c0812455753e915f5 (patch)
tree1a9a96d92f0b38e1b782662717eec8e6d77863b7
parentb7a3cbd3c0e145c67d9955df281f616010ba2d8a (diff)
Don't use QByteArray replace() overload that was only added in Qt 4.7
The bad thing is that another overload, added in Qt 4.5, was silently used in 4.5-4.6 versions which predictably did the wrong thing.
-rw-r--r--odb/qt/basic/mysql/qbyte-array-traits.hxx8
-rw-r--r--odb/qt/basic/pgsql/qbyte-array-traits.hxx8
-rw-r--r--odb/qt/basic/sqlite/qbyte-array-traits.hxx8
3 files changed, 21 insertions, 3 deletions
diff --git a/odb/qt/basic/mysql/qbyte-array-traits.hxx b/odb/qt/basic/mysql/qbyte-array-traits.hxx
index 52e620c..a80187d 100644
--- a/odb/qt/basic/mysql/qbyte-array-traits.hxx
+++ b/odb/qt/basic/mysql/qbyte-array-traits.hxx
@@ -36,7 +36,13 @@ namespace odb
if (is_null)
v = QByteArray ();
else
- v.replace (0, v.size (), b.data (), static_cast<int> (n));
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
}
static void
diff --git a/odb/qt/basic/pgsql/qbyte-array-traits.hxx b/odb/qt/basic/pgsql/qbyte-array-traits.hxx
index cf0477e..8491794 100644
--- a/odb/qt/basic/pgsql/qbyte-array-traits.hxx
+++ b/odb/qt/basic/pgsql/qbyte-array-traits.hxx
@@ -36,7 +36,13 @@ namespace odb
if (is_null)
v = QByteArray ();
else
- v.replace (0, v.size (), b.data (), static_cast<int> (n));
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
}
static void
diff --git a/odb/qt/basic/sqlite/qbyte-array-traits.hxx b/odb/qt/basic/sqlite/qbyte-array-traits.hxx
index 0d1437e..9c563f3 100644
--- a/odb/qt/basic/sqlite/qbyte-array-traits.hxx
+++ b/odb/qt/basic/sqlite/qbyte-array-traits.hxx
@@ -36,7 +36,13 @@ namespace odb
if (is_null)
v = QByteArray ();
else
- v.replace (0, v.size (), b.data (), static_cast<int> (n));
+ {
+ // Note that we cannot use replace() here since a suitable
+ // overload was only added in Qt 4.7.
+ //
+ v.resize (static_cast<int> (n));
+ std::memcpy (v.data (), b.data (), n);
+ }
}
static void