Fix MSVC warning C4267 in qstring.cpp

Fix warnings

  qstring.cpp(9650): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data
  qstring.cpp(9654): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data

QDataStream::writeBytes expects an uint as second parameter, not size_t.

This reverts parts of 744e55b85a96b37a, where the explicit cast to size_t
was introduced.

Change-Id: I2750a6f48fc09730aa9fa21dcc31f82e33b48b8b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 189bc8dd1546c56d9c4986024a345dcb2604ed04)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Kai Koehne 2020-12-08 12:55:34 +01:00 committed by Qt Cherry-pick Bot
parent f60f62f091
commit 49f27c0eaa

View File

@ -9622,11 +9622,13 @@ QDataStream &operator<<(QDataStream &out, const QString &str)
} else {
if (!str.isNull() || out.version() < 3) {
if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
out.writeBytes(reinterpret_cast<const char *>(str.unicode()), size_t(sizeof(QChar) * str.length()));
out.writeBytes(reinterpret_cast<const char *>(str.unicode()),
static_cast<uint>(sizeof(QChar) * str.length()));
} else {
QVarLengthArray<char16_t> buffer(str.length());
qbswap<sizeof(char16_t)>(str.constData(), str.length(), buffer.data());
out.writeBytes(reinterpret_cast<const char *>(buffer.data()), size_t(sizeof(char16_t) * buffer.size()));
out.writeBytes(reinterpret_cast<const char *>(buffer.data()),
static_cast<uint>(sizeof(char16_t) * buffer.size()));
}
} else {
// write null marker