diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-02-17 10:06:42 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-03-21 14:23:53 +0000 |
commit | d3b6ef6ccfa93a93d7a80d71bc2779f4ca7600f6 (patch) | |
tree | 42c5122988202de81dbf7ca0a6f737f347438f17 /src/corelib/io/qfile.cpp | |
parent | 79493a3ee129c014298c6ef694415b8f0fffd74b (diff) |
QFile::rename: fix the error message if renaming a file by copy fails
The QFile out variable cannot be open because if out.open() succeeded,
we could never reach this line. Instead, we want to capture *why* either
the source or the destination failed to open.
Task-number: QTBUG-66445
Change-Id: I940917d6763842499b18fffd15142f231bf34a47
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r-- | src/corelib/io/qfile.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 33b0b2eb66..3166fa1b83 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -676,8 +676,11 @@ QFile::rename(const QString &newName) return !error; } close(); + d->setError(QFile::RenameError, + tr("Cannot open destination file: %1").arg(out.errorString())); + } else { + d->setError(QFile::RenameError, errorString()); } - d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString()); } return false; } |