summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-08 06:52:22 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-04-08 06:52:22 +0000
commit4cee9928f25926581c5bfcffeb648d89e0b232ec (patch)
treee4b3d5109b177a607c2275ed4729ea0a23e0d45c /src/corelib/io/qiodevice.cpp
parent0d4232f53100eb04f8aa85ea2a7aee395baf337f (diff)
parent20cac3d9c9c22153e9e316daff32b6050ff6be6b (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 7eb917c71f..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 {
@@ -1629,6 +1631,23 @@ QString QIODevice::errorString() const
\sa read(), write()
*/
+/*!
+ \internal
+ \fn int qt_subtract_from_timeout(int timeout, int elapsed)
+
+ Reduces the \a timeout by \a elapsed, taking into account that -1 is a
+ special value for timeouts.
+*/
+
+int qt_subtract_from_timeout(int timeout, int elapsed)
+{
+ if (timeout == -1)
+ return -1;
+
+ timeout = timeout - elapsed;
+ return timeout < 0 ? 0 : timeout;
+}
+
#if !defined(QT_NO_DEBUG_STREAM)
QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)