summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument.cpp
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2009-11-23 16:10:10 +0100
committerTrond Kjernåsen <trond@trolltech.com>2009-11-23 16:14:15 +0100
commitddd885ae9a46f8abcc4e5eb45bb4c53d7f86f4c2 (patch)
tree83d189e6feb3a0a2dcd047e2a7839c1d30830fba /src/gui/text/qtextdocument.cpp
parent0bad605066f4cacabb2547b9b8895b69dac3d431 (diff)
Fixed endless loop when printing a QTextDocument.
If the user enters a valid page range, which lies outside of the actual number of printable pages, we can't detect that until the document has been paginated. Task-number: QTBUG-6051 Reviewed-by: Kim
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r--src/gui/text/qtextdocument.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 048325c036..523dd18c86 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1767,6 +1767,12 @@ void QTextDocument::print(QPrinter *printer) const
fromPage = qMax(1, fromPage);
toPage = qMin(doc->pageCount(), toPage);
+ if (toPage < fromPage) {
+ // if the user entered a page range outside the actual number
+ // of printable pages, just return
+ return;
+ }
+
if (printer->pageOrder() == QPrinter::LastPageFirst) {
int tmp = fromPage;
fromPage = toPage;