diff options
author | João Abecasis <joao@abecasis.name> | 2009-04-29 14:36:48 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-04-30 08:56:41 (GMT) |
commit | 60e5266eec332792d23f13ea63203f45f8e0f430 (patch) | |
tree | 6a5a3b99d635f9d5cf0e6924f45a0c9ecfa1776b /src/corelib/io | |
parent | d355e069ca1952504ef8cc6fb44350b53314d5d5 (diff) | |
download | Qt-60e5266eec332792d23f13ea63203f45f8e0f430.zip Qt-60e5266eec332792d23f13ea63203f45f8e0f430.tar.gz Qt-60e5266eec332792d23f13ea63203f45f8e0f430.tar.bz2 |
Fixed QFile::copy/rename fail after initial failed attempt
These functions were checking the error state after calling close(),
without first resetting the error state. Turns out close() only resets
the error state if isOpen() returns false.
Also, the fallback for the copy operation opens the file for reading
but wasn't closing it again afterwards. Now fixed.
Added autotests to cover these situations.
Reviewed-by: MariusSO
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfile.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index d7da800..04750b0 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -708,6 +708,7 @@ QFile::rename(const QString &newName) d->setError(QFile::RenameError, tr("Destination file exists")); return false; } + unsetError(); close(); if(error() == QFile::NoError) { if (fileEngine()->rename(newName)) { @@ -849,6 +850,7 @@ QFile::copy(const QString &newName) d->setError(QFile::CopyError, tr("Destination file exists")); return false; } + unsetError(); close(); if(error() == QFile::NoError) { if(fileEngine()->copy(newName)) { @@ -908,6 +910,7 @@ QFile::copy(const QString &newName) out.setAutoRemove(false); #endif } + close(); } if(!error) { QFile::setPermissions(newName, permissions()); |