diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-06-10 09:10:49 (GMT) |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2011-06-10 09:11:48 (GMT) |
commit | 6b91affb9a355e668bc9d06dee580d95230ac63a (patch) | |
tree | 341248589b104d4f329ee75e7a1188e3e00d277c /src/corelib | |
parent | f2bfd1f7913e21f8946ea9aa2f96ee4e38a942eb (diff) | |
download | Qt-6b91affb9a355e668bc9d06dee580d95230ac63a.zip Qt-6b91affb9a355e668bc9d06dee580d95230ac63a.tar.gz Qt-6b91affb9a355e668bc9d06dee580d95230ac63a.tar.bz2 |
fix an incorrect OpenMode flags handling in QBuffer::open()
which leads to absurd statement (QBuffer::open() == !QBuffer::isOpen()) to be true.
also treat Truncate as (Truncate | WriteOnly) to satisfy lazy ones
Reviewed-by: Joao
Merge-request: 2612
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qbuffer.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 38e406b..35e7b68 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -333,23 +333,18 @@ bool QBuffer::open(OpenMode flags) { Q_D(QBuffer); - if ((flags & Append) == Append) + if ((flags & (Append | Truncate)) != 0) flags |= WriteOnly; - setOpenMode(flags); - if (!(isReadable() || isWritable())) { - qWarning("QFile::open: File access not specified"); + if ((flags & (ReadOnly | WriteOnly)) == 0) { + qWarning("QBuffer::open: Buffer access not specified"); return false; } - if ((flags & QIODevice::Truncate) == QIODevice::Truncate) { + if ((flags & Truncate) == Truncate) d->buf->resize(0); - } - if ((flags & QIODevice::Append) == QIODevice::Append) // append to end of buffer - seek(d->buf->size()); - else - seek(0); + d->ioIndex = (flags & Append) == Append ? d->buf->size() : 0; - return true; + return QIODevice::open(flags); } /*! |