diff options
author | João Abecasis <joao@trolltech.com> | 2010-01-07 13:50:14 (GMT) |
---|---|---|
committer | João Abecasis <joao@trolltech.com> | 2010-01-07 15:33:26 (GMT) |
commit | 6bf1674f1e51fd8b08783035cda7493ecd63b443 (patch) | |
tree | 6fdd8a78c3d8d652ceebc4253174e5dd7365f834 /src/corelib/io/qfile.cpp | |
parent | 3b57425aa11e5e1536016ccccdde7657493a0dc8 (diff) | |
download | Qt-6bf1674f1e51fd8b08783035cda7493ecd63b443.zip Qt-6bf1674f1e51fd8b08783035cda7493ecd63b443.tar.gz Qt-6bf1674f1e51fd8b08783035cda7493ecd63b443.tar.bz2 |
Don't drop errors from flush on QFile::close
Now that we don't defer to the file engine for the write buffer it is
doubly more important to retain errors from flush. The logic employed
reproduces what we already had in QFSFileEngine::close, earliest error
stays.
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r-- | src/corelib/io/qfile.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index eb6f5be..b6fa5f3 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1386,11 +1386,14 @@ QFile::close() Q_D(QFile); if(!isOpen()) return; - flush(); + bool flushed = flush(); QIODevice::close(); - unsetError(); - if(!fileEngine()->close()) + + // keep earlier error from flush + if (fileEngine()->close() && flushed) + unsetError(); + else if (flushed) d->setError(fileEngine()->error(), fileEngine()->errorString()); } |