summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-03-26 15:00:14 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-04-02 14:29:48 (GMT)
commita2fcc4a5ae6addf3688a3686cc89ae20d5426242 (patch)
tree5b9b5c8c19fc1cc34e43a585e877ad473248ea07
parentba1dee09daef790883e53d91f4f02865c75e6d57 (diff)
downloadQt-a2fcc4a5ae6addf3688a3686cc89ae20d5426242.zip
Qt-a2fcc4a5ae6addf3688a3686cc89ae20d5426242.tar.gz
Qt-a2fcc4a5ae6addf3688a3686cc89ae20d5426242.tar.bz2
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
-rw-r--r--src/corelib/io/qfile.cpp12
1 files 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;
}
}