summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-01-06 12:15:12 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-01-06 15:40:14 (GMT)
commit859bc191b1096c02cebad011c75a4573289904e7 (patch)
tree272798d460cb4e69a8de1c2c90bac0d626af9c33 /src
parent5529a356368b31998e859e3fb5f94e85c16447aa (diff)
downloadQt-859bc191b1096c02cebad011c75a4573289904e7.zip
Qt-859bc191b1096c02cebad011c75a4573289904e7.tar.gz
Qt-859bc191b1096c02cebad011c75a4573289904e7.tar.bz2
QIODevice: Fix readAll()
My patch from yesterday did not have any effect: Instead of really using what was in the buffer, it used it but then read it from the underlying device anyway. Thanks Ritt Konstantin and Joao. Reviewed-by: joao
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qiodevice.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 1e98473..4e14ba8 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -970,6 +970,7 @@ QByteArray QIODevice::readAll()
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
result = d->buffer.readAll();
readBytes = result.size();
+ d->pos += readBytes;
}
qint64 theSize;
@@ -985,8 +986,8 @@ QByteArray QIODevice::readAll()
} else {
// Read it all in one go.
// If resize fails, don't read anything.
- result.resize(int(theSize - d->pos));
- readBytes = read(result.data(), result.size());
+ result.resize(int(readBytes + theSize - d->pos));
+ readBytes += read(result.data() + readBytes, result.size() - readBytes);
}
if (readBytes <= 0)