From a851868e63311622bb83d2e08388b34c4d6d869e Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 12 Jun 2015 11:49:24 +0300 Subject: [PATCH] QIODevice::atEnd(): fix debug message output For sequential devices, duplicated bytesAvailable() calls can produce different results. To avoid a wrong output, print exactly the same value as would be returned. Change-Id: I02615dd7375516f7b263eea56bfcf15e2889e6e3 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qiodevice.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 3c8e97e3c6..1b3c58f8f9 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -693,12 +693,13 @@ bool QIODevice::seek(qint64 pos) bool QIODevice::atEnd() const { Q_D(const QIODevice); + const bool result = (d->openMode == NotOpen || (d->buffer.isEmpty() + && bytesAvailable() == 0)); #if defined QIODEVICE_DEBUG printf("%p QIODevice::atEnd() returns %s, d->openMode == %d, d->pos == %lld\n", this, - (d->openMode == NotOpen || d->pos == size()) ? "true" : "false", int(d->openMode), - d->pos); + result ? "true" : "false", int(d->openMode), d->pos); #endif - return d->openMode == NotOpen || (d->buffer.isEmpty() && bytesAvailable() == 0); + return result; } /*!