summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimagewriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qimagewriter.cpp')
-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;