qt4/src/poppler-pdf-converter.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
New commits:
commit e92255296511cae9cbbac8de800d8b26e5f681f1
Author: Pino Toscano <[EMAIL PROTECTED]>
Date: Sun Oct 5 15:57:06 2008 +0200
[Qt4] when the PDF exporting fails, delete the file if it was created by
the (failed) exporting
diff --git a/qt4/src/poppler-pdf-converter.cc b/qt4/src/poppler-pdf-converter.cc
index 7f90416..995d46e 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;
}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler