summaryrefslogtreecommitdiff
path: root/src/corelib/io/qfile.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-03-26 16:00:14 +0100
committerJoão Abecasis <joao@abecasis.name>2009-04-02 16:29:48 +0200
commita2fcc4a5ae6addf3688a3686cc89ae20d5426242 (patch)
tree5b9b5c8c19fc1cc34e43a585e877ad473248ea07 /src/corelib/io/qfile.cpp
parentba1dee09daef790883e53d91f4f02865c75e6d57 (diff)
downloadqt4-tools-a2fcc4a5ae6addf3688a3686cc89ae20d5426242.tar.gz
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
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-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 d8f08c9638..986c6f53f5 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;
}
}