summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorJoão Abecasis <joao@trolltech.com>2010-01-07 14:54:06 (GMT)
committerJoão Abecasis <joao@trolltech.com>2010-01-07 15:33:26 (GMT)
commit183be5348e53ef1df9a6e1eb82f10f24ce612f40 (patch)
treebdd08361c176119288bbf0ce9c1c22affb16da1b /src/corelib/io
parent6bf1674f1e51fd8b08783035cda7493ecd63b443 (diff)
downloadQt-183be5348e53ef1df9a6e1eb82f10f24ce612f40.zip
Qt-183be5348e53ef1df9a6e1eb82f10f24ce612f40.tar.gz
Qt-183be5348e53ef1df9a6e1eb82f10f24ce612f40.tar.bz2
Fix bugs evidenced by change to keep flush errors on QFile::close
When closing a file, the contents of the write buffer should be emptied even in the case where flush fails, so it doesn't leak to subsequent files opened through the same instance. This is inline with what would happen with native close on a buffered device. Also changed the resource file engine to succeed on flush. Since all writes fail there, logically it's write buffer is empty and flush should succeed. This keeps auto-tests happy :-) tst_QFile::fullDisk auto-test extended to ensure re-opening QFile does not keep the write buffer alive. Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfile.cpp3
-rw-r--r--src/corelib/io/qresource.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index b6fa5f3..6395cc7 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1389,6 +1389,9 @@ QFile::close()
bool flushed = flush();
QIODevice::close();
+ // reset write buffer
+ d->lastWasWrite = false;
+ d->writeBuffer.clear();
// keep earlier error from flush
if (fileEngine()->close() && flushed)
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 3d54969..adfbb15 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1285,7 +1285,7 @@ bool QResourceFileEngine::close()
bool QResourceFileEngine::flush()
{
- return false;
+ return true;
}
qint64 QResourceFileEngine::read(char *data, qint64 len)