diff options
author | João Abecasis <joao@abecasis.name> | 2009-03-26 15:53:18 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-04-02 14:29:48 (GMT) |
commit | 8d50038174faf315a389010af3a680d865f6843a (patch) | |
tree | 0e211b6f9e93c2694e9b0e80eb4f3857b7055a4a | |
parent | a2fcc4a5ae6addf3688a3686cc89ae20d5426242 (diff) | |
download | Qt-8d50038174faf315a389010af3a680d865f6843a.zip Qt-8d50038174faf315a389010af3a680d865f6843a.tar.gz Qt-8d50038174faf315a389010af3a680d865f6843a.tar.bz2 |
Renaming a file does not change QFile's fileName
QFile made no attempt to reset the file name on a rename. We now reset
the fileEngine's fileName if it was able to handle the rename.
Otherwise, we call setFileName, which will result in reallocation of the
fileEngine.
Task-number: 244485
Reviewed-by: mariusSO
-rw-r--r-- | src/corelib/io/qfile.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 986c6f5..f0a6676 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -712,6 +712,9 @@ QFile::rename(const QString &newName) if(error() == QFile::NoError) { if (fileEngine()->rename(newName)) { unsetError(); + // engine was able to handle the new name so we just reset it + fileEngine()->setFileName(newName); + d->fileName = newName; return true; } @@ -741,6 +744,8 @@ QFile::rename(const QString &newName) } if (error) out.remove(); + else + setFileName(newName); return !error; } } |