diff options
author | David Boddie <dboddie@trolltech.com> | 2009-05-20 12:30:38 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-05-20 12:30:38 (GMT) |
commit | e28412e4c2389c1765441cec02baed58a63dd29c (patch) | |
tree | 458d92f3cce5e7532d0569a251f5c3f7ca2f95a8 /src/corelib/io | |
parent | fc6e0155cc3fa9beb3b48704a1effe87a74c2779 (diff) | |
parent | 095fe67c4a669f038ea7c14613efe5cb9453fa74 (diff) | |
download | Qt-e28412e4c2389c1765441cec02baed58a63dd29c.zip Qt-e28412e4c2389c1765441cec02baed58a63dd29c.tar.gz Qt-e28412e4c2389c1765441cec02baed58a63dd29c.tar.bz2 |
Merge branch '4.5' of ../qt-45-documentation
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index b6c4eb1..2ccc6ea 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -949,9 +949,9 @@ QByteArray QIODevice::readAll() QByteArray tmp; if (d->isSequential() || size() == 0) { - // Read it in chunks, bytesAvailable() is unreliable for sequential - // devices. - const int chunkSize = 4096; + // Read it in chunks. Use bytesAvailable() as an unreliable hint for + // sequential devices, but try to read 4K as a minimum. + int chunkSize = qMax(qint64(4096), bytesAvailable()); qint64 totalRead = 0; forever { tmp.resize(tmp.size() + chunkSize); @@ -960,6 +960,7 @@ QByteArray QIODevice::readAll() if (readBytes <= 0) return tmp; totalRead += readBytes; + chunkSize = qMax(qint64(4096), bytesAvailable()); } } else { // Read it all in one go. |