summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qbuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qbuffer.cpp')
-rw-r--r--src/corelib/io/qbuffer.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index ba84428275..4e513bc7cf 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -282,12 +282,15 @@ void QBuffer::setData(const char *data, qsizetype size)
qWarning("QBuffer::setData: Buffer is open");
return;
}
- d->buf->replace(qsizetype(0), d->buf->size(), // ### QByteArray lacks assign(ptr, n)
- data, size);
+ d->buf->assign(data, data + size);
}
/*!
\reimp
+
+ Unlike QFile, opening a QBuffer QIODevice::WriteOnly does not truncate it.
+ However, pos() is set to 0. Use QIODevice::Append or QIODevice::Truncate to
+ change either behavior.
*/
bool QBuffer::open(OpenMode flags)
{
@@ -397,7 +400,7 @@ qint64 QBuffer::writeData(const char *data, qint64 len)
if (required > quint64(d->buf->size())) { // capacity exceeded
// The following must hold, since qsizetype covers half the virtual address space:
- Q_ASSUME(required <= quint64((std::numeric_limits<qsizetype>::max)()));
+ Q_ASSERT(required <= quint64((std::numeric_limits<qsizetype>::max)()));
d->buf->resize(qsizetype(required));
if (quint64(d->buf->size()) != required) { // could not resize
qWarning("QBuffer::writeData: Memory allocation error");