summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-02-17 10:06:42 -0800
committerThiago Macieira <thiago.macieira@intel.com>2018-03-21 14:23:53 +0000
commitd3b6ef6ccfa93a93d7a80d71bc2779f4ca7600f6 (patch)
tree42c5122988202de81dbf7ca0a6f737f347438f17 /src/corelib
parent79493a3ee129c014298c6ef694415b8f0fffd74b (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')
-rw-r--r--src/corelib/io/qfile.cpp5
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;
}