diff options
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 0e5a2de..4e14ba8 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -965,7 +965,16 @@ QByteArray QIODevice::readAll() QByteArray result; qint64 readBytes = 0; - if (d->isSequential() || (readBytes = size()) == 0) { + + // flush internal read buffer + if (!(d->openMode & Text) && !d->buffer.isEmpty()) { + result = d->buffer.readAll(); + readBytes = result.size(); + d->pos += readBytes; + } + + qint64 theSize; + if (d->isSequential() || (theSize = size()) == 0) { // Size is unknown, read incrementally. qint64 readResult; do { @@ -977,8 +986,8 @@ QByteArray QIODevice::readAll() } else { // Read it all in one go. // If resize fails, don't read anything. - result.resize(int(readBytes - 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) |