summaryrefslogtreecommitdiff
path: root/qt4
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2008-10-05 15:57:06 +0200
committerPino Toscano <pino@kde.org>2008-10-05 15:57:06 +0200
commite92255296511cae9cbbac8de800d8b26e5f681f1 (patch)
treeb84fd7b1b20329bc6efcc42e2dda40b6ed9344a6 /qt4
parent360f470b852e37d400949343763a18bf598820e8 (diff)
[Qt4] when the PDF exporting fails, delete the file if it was created by
the (failed) exporting
Diffstat (limited to 'qt4')
-rw-r--r--qt4/src/poppler-pdf-converter.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/qt4/src/poppler-pdf-converter.cc b/qt4/src/poppler-pdf-converter.cc
index 7f904165..995d46ef 100644
--- a/qt4/src/poppler-pdf-converter.cc
+++ b/qt4/src/poppler-pdf-converter.cc
@@ -23,6 +23,8 @@
#include "poppler-converter-private.h"
#include "poppler-qiodeviceoutstream-private.h"
+#include <QtCore/QFile>
+
namespace Poppler {
class PDFConverterPrivate : public BaseConverterPrivate
@@ -73,6 +75,10 @@ bool PDFConverter::convert()
if (!dev)
return false;
+ bool deleteFile = false;
+ if (QFile *file = qobject_cast<QFile*>(dev))
+ deleteFile = !file->exists();
+
bool success;
QIODeviceOutStream stream(dev);
if (d->opts & WithChanges)
@@ -84,6 +90,13 @@ bool PDFConverter::convert()
success = d->document->doc->saveWithoutChangesAs(&stream);
}
d->closeDevice();
+ if (!success)
+ {
+ if (deleteFile)
+ {
+ qobject_cast<QFile*>(dev)->remove();
+ }
+ }
return success;
}