summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2015-03-28 16:47:41 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2015-04-04 08:40:01 +0000
commitf40cf77b0fa1cd5353ca866a7a5799da9f303081 (patch)
treec78a9f09ded0afaa66e289edd1db644fa57f8091 /src/corelib/io/qiodevice.cpp
parent6dcbaa487d222440c2aeeb5f0ad3bc6337d52f5d (diff)
QIODevice: do not change the 'pos' member for sequential devices
Concept of 'current position' exists only for random-access devices. As documented, for sequential devices QIODevice::pos() must always return 0. Prevent a modification of the internal 'pos' member in QIODevice::readAll() method to follow this rule. Change-Id: Ida2ee6a629ccfc3068d62f95ab1064ada13fdda5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index f2655dab3c..7a87a78c60 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -972,6 +972,7 @@ QByteArray QIODevice::readAll()
QByteArray result;
qint64 readBytes = 0;
+ const bool sequential = d->isSequential();
// flush internal read buffer
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
@@ -979,11 +980,12 @@ QByteArray QIODevice::readAll()
return QByteArray();
result = d->buffer.readAll();
readBytes = result.size();
- d->pos += readBytes;
+ if (!sequential)
+ d->pos += readBytes;
}
qint64 theSize;
- if (d->isSequential() || (theSize = size()) == 0) {
+ if (sequential || (theSize = size()) == 0) {
// Size is unknown, read incrementally.
qint64 readResult;
do {