diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-23 10:17:53 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-09-24 21:02:03 +0000 |
commit | b76c70173a1639876bd89b24ef59cfb7e07d83e2 (patch) | |
tree | 0cfeb5fc03561fcca100f3376c3fdd92fbd3c66e /src | |
parent | 5104a529ce5aea5e94101770ece188b98f20baaa (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>
(cherry picked from commit 7aaa7debc455516cbb1b1f536e990b9154272f64)
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index b479ecacb1..4713210ee6 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); |