From 0aec32fc7df603fb4db104b5ad3b14e809ac18d6 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sun, 12 Jan 2014 19:16:04 +0100 Subject: [PATCH] Don't try to print something with invalid sizes Unfortunately as we can't add new strings to stable versions it'd say "unwnown error" if that happens Don't think it's too bad since this shouldn't be happening much BUGS: 329562 --- core/generator.h | 3 ++- generators/poppler/generator_pdf.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/generator.h b/core/generator.h index a5a971b6c..3cf40c2f2 100644 --- a/core/generator.h +++ b/core/generator.h @@ -358,7 +358,8 @@ class OKULAR_EXPORT Generator : public QObject InvalidPrinterStatePrintError, UnableToFindFilePrintError, NoFileToPrintError, - NoBinaryToPrintError + NoBinaryToPrintError, + InvalidPageSizePrintError ///< @since 0.18.2 (KDE 4.12.2) }; /** diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index 1a44523a1..839a32414 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -1116,6 +1116,13 @@ bool PDFGenerator::print( QPrinter& printer ) int width = printer.width(); int height = printer.height(); #endif + + if (width <= 0 || height <= 0) + { + lastPrintError = InvalidPageSizePrintError; + return false; + } + // Create the tempfile to send to FilePrinter, which will manage the deletion KTemporaryFile tf; tf.setSuffix( ".ps" );