From 6bf1674f1e51fd8b08783035cda7493ecd63b443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 7 Jan 2010 14:50:14 +0100 Subject: 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 --- src/corelib/io/qfile.cpp | 9 ++++++--- 1 file 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()); } -- cgit v0.12