summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2016-12-22 11:31:12 +0100
committerRobin Burchell <robin.burchell@viroteck.net>2016-12-22 11:51:12 +0000
commit16829f0bae1a0ea24a31bc3101ad33ddf55aa261 (patch)
tree95631934b36c60bff18f5ea5b5626daf94b8b46d /src/gui
parente1113cae9865850bd8f5bc7f1331027e07ce1e49 (diff)
QImageWriter: Explain slightly strange looking logic in canWrite
Change-Id: Ic0fa4783351144ad8739669f1655b2fb0639a43d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimagewriter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index f3af2738af..fd2c51ebd8 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -705,6 +705,11 @@ bool QImageWriter::canWrite() const
if (QFile *file = qobject_cast<QFile *>(d->device)) {
const bool remove = !file->isOpen() && !file->exists();
const bool result = d->canWriteHelper();
+
+ // This looks strange (why remove if it doesn't exist?) but the issue
+ // here is that canWriteHelper will create the file in the process of
+ // checking if the write can succeed. If it subsequently fails, we
+ // should remove that empty file.
if (!result && remove)
file->remove();
return result;