diff --git a/src/core/io/qfile.cpp b/src/core/io/qfile.cpp index 391400cef..45f14d3df 100644 --- a/src/core/io/qfile.cpp +++ b/src/core/io/qfile.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE //************* QFilePrivate QFilePrivate::QFilePrivate() : fileEngine(0), lastWasWrite(false), - error(QFile::NoError), cachedSize(0) + error(QFile::NoError) { } @@ -1067,10 +1067,8 @@ bool QFile::resize(qint64 sz) seek(sz); if(d->fileEngine->setSize(sz)) { unsetError(); - d->cachedSize = sz; return true; } - d->cachedSize = 0; d->setError(QFile::ResizeError, d->fileEngine->errorString()); return false; } @@ -1225,8 +1223,7 @@ qint64 QFile::size() const Q_D(const QFile); if (!d->ensureFlushed()) return 0; - d->cachedSize = fileEngine()->size(); - return d->cachedSize; + return fileEngine()->size(); } /*! @@ -1260,11 +1257,6 @@ bool QFile::atEnd() const return d->fileEngine->atEnd(); } - // if it looks like we are at the end, or if size is not cached, - // fall through to bytesAvailable() to make sure. - if (pos() < d->cachedSize) - return false; - // Fall back to checking how much is available (will stat files). return bytesAvailable() == 0; } @@ -1328,11 +1320,6 @@ qint64 QFile::readLineData(char *data, qint64 maxlen) read = QIODevice::readLineData(data, maxlen); } - if (read < maxlen) { - // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked - d->cachedSize = 0; - } - return read; } @@ -1354,11 +1341,6 @@ qint64 QFile::readData(char *data, qint64 len) d->setError(err, d->fileEngine->errorString()); } - if (read < len) { - // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked - d->cachedSize = 0; - } - return read; } diff --git a/src/core/io/qfile_p.h b/src/core/io/qfile_p.h index f0e78345b..e72e7932f 100644 --- a/src/core/io/qfile_p.h +++ b/src/core/io/qfile_p.h @@ -74,8 +74,6 @@ protected: QFile::FileError error; void setError(QFile::FileError err); void setError(QFile::FileError err, const QString &errorString); - - mutable qint64 cachedSize; }; QT_END_NAMESPACE