diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-02 16:21:12 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-03 14:20:43 (GMT) |
commit | 47e8fc1c237adb9742140f834226e9da9f60c2f2 (patch) | |
tree | 77e2d796664f763f8c4f4dc50aac027c21602bb5 /src/corelib/tools/qstringbuilder.cpp | |
parent | 61dfa74bb542f495eb5ff25e3f91b9065eb1cfdd (diff) | |
download | Qt-47e8fc1c237adb9742140f834226e9da9f60c2f2.zip Qt-47e8fc1c237adb9742140f834226e9da9f60c2f2.tar.gz Qt-47e8fc1c237adb9742140f834226e9da9f60c2f2.tar.bz2 |
Improve handling QByteArray with QStringBuilder
Instead of relying on the old behavior of the deprecated QString(QByteArray)
constructor which stops copying the byte array at the null termination
character if there is one embedded in the array, we copy the whole provided
QByteArray object into the QString when QStringBuilder is used.
Reviewed-by: Harald Fernengel
Diffstat (limited to 'src/corelib/tools/qstringbuilder.cpp')
-rw-r--r-- | src/corelib/tools/qstringbuilder.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 53368eb..7d75de7 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -150,8 +150,8 @@ QT_BEGIN_NAMESPACE void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out) { #ifndef QT_NO_TEXTCODEC - if (QString::codecForCStrings) { - QString tmp = QString::fromAscii(a); + if (QString::codecForCStrings && len) { + QString tmp = QString::fromAscii(a, len > 0 ? len - 1 : -1); memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size()); out += tmp.length(); return; |