From a2fcc4a5ae6addf3688a3686cc89ae20d5426242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Mar 2009 16:00:14 +0100 Subject: QFile::rename didn't always return false when method failed The fallback implementation for rename would return true in some situations where the move failed. Also the destination file might be created and left there in these cases. Task-number: 244500 Reviewed-by: mariusSO --- src/corelib/io/qfile.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index d8f08c9..986c6f5 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -731,10 +731,16 @@ QFile::rename(const QString &newName) } if (read == -1) { d->setError(QFile::RenameError, in.errorString()); - return true; + error = true; + } + if(!error) { + if (!in.remove()) { + d->setError(QFile::RenameError, tr("Cannot remove source file")); + error = true; + } } - if(!error) - in.remove(); + if (error) + out.remove(); return !error; } } -- cgit v0.12