summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-23 10:17:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-05-23 08:26:57 +0000
commit7aaa7debc455516cbb1b1f536e990b9154272f64 (patch)
treeecd231ea327c996bfc5eb0e4726436631da1c361 /src
parent4deea4b905ea1ad32fde317f8556a5c8cdd775cd (diff)
QWin32PrintEngine: Fix crash in drawPixmap(), drawImage()
Use the printer's HDC instead of the screen HDC for StretchBlt(). Patch as contributed via bug report. Task-number: QTBUG-59689 Task-number: QTBUG-66325 Change-Id: I9b5d6ddd3f0e9e68f2a003ca9ed20ece20dccef8 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index ca4d1d0bd6..6f263e5ea8 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -587,12 +587,9 @@ void QWin32PrintEngine::drawPixmap(const QRectF &targetRect,
QPixmap p = QPixmap::fromImage(img);
HBITMAP hbitmap = qt_pixmapToWinHBITMAP(p, HBitmapNoAlpha);
- HDC display_dc = GetDC(0);
- HDC hbitmap_hdc = CreateCompatibleDC(display_dc);
+ HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
- ReleaseDC(0, display_dc);
-
if (!StretchBlt(d->hdc, qRound(tposx - xform_offset_x), qRound(tposy - xform_offset_y), width, height,
hbitmap_hdc, 0, 0, p.width(), p.height(), SRCCOPY))
qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed");
@@ -620,13 +617,10 @@ void QWin32PrintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, cons
} else {
int dc_state = SaveDC(d->hdc);
- HDC display_dc = GetDC(0);
HBITMAP hbitmap = qt_pixmapToWinHBITMAP(pm, HBitmapNoAlpha);
- HDC hbitmap_hdc = CreateCompatibleDC(display_dc);
+ HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
- ReleaseDC(0, display_dc);
-
QRectF trect = d->painterMatrix.mapRect(r);
int tx = int(trect.left() * d->stretch_x + d->origin_x);
int ty = int(trect.top() * d->stretch_y + d->origin_y);