From 51ff0449344cfb110f316288f44d6300340787dd Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 22 Jul 2014 15:59:45 +0200 Subject: Check if Start/EndPage returns non-positive value when error checking StartPage and EndPage are documented to return a non-positive value (0 or less) when they fail, therefore it is not enough to check if !StartPage. Checking if is 0 or less is more accurate. Change-Id: Ia0ff43da4e4309ba0a5983e91a0ad583aad0a955 Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprintengine_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/printsupport/kernel') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index b97dc6d2c2..98a0844baa 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -203,7 +203,7 @@ bool QWin32PrintEngine::newPage() bool transparent = GetBkMode(d->hdc) == TRANSPARENT; - if (!EndPage(d->hdc)) { + if (EndPage(d->hdc) <= 0) { qErrnoWarning("QWin32PrintEngine::newPage: EndPage failed"); return false; } @@ -216,7 +216,7 @@ bool QWin32PrintEngine::newPage() d->reinit = false; } - if (!StartPage(d->hdc)) { + if (StartPage(d->hdc) <= 0) { qErrnoWarning("Win32PrintEngine::newPage: StartPage failed"); return false; } @@ -235,7 +235,7 @@ bool QWin32PrintEngine::newPage() bool success = false; if (d->hdc && d->state == QPrinter::Active) { - if (EndPage(d->hdc) != SP_ERROR) { + if (EndPage(d->hdc) > 0) { // reinitialize the DC before StartPage if needed, // because resetdc is disabled between calls to the StartPage and EndPage functions // (see StartPage documentation in the Platform SDK:Windows GDI) @@ -248,7 +248,7 @@ bool QWin32PrintEngine::newPage() qErrnoWarning("QWin32PrintEngine::newPage(), ResetDC failed (2)"); d->reinit = false; } - success = (StartPage(d->hdc) != SP_ERROR); + success = (StartPage(d->hdc) > 0); } if (!success) { d->state = QPrinter::Aborted; -- cgit v1.2.3