QWin32PrintEngine: Fix uninitialized memory read of dpi_x, dpi_y

Discovered by purify:
QWin32PrintEnginePrivate::initialize() called updateMetrics()
via updatePageLayout() after initHDC(), so dpi_x, dpi_y
were accessed before initialized from the display resolution.
Fix by moving the call initHDC() up and giving default
values.

Change-Id: Ia360c06d156e569ca6b1472ec5b5cdc52948f913
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
bb10
Friedemann Kleint 2016-08-30 13:42:43 +02:00
parent ce2815b43c
commit 579283507c
2 changed files with 7 additions and 3 deletions

View File

@ -918,14 +918,14 @@ void QWin32PrintEnginePrivate::initialize()
Q_ASSERT(hPrinter);
Q_ASSERT(pInfo);
initHDC();
if (devMode) {
num_copies = devMode->dmCopies;
devMode->dmCollate = DMCOLLATE_TRUE;
updatePageLayout();
}
initHDC();
#if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS
qDebug() << "QWin32PrintEngine::initialize()";
debugMetrics();

View File

@ -124,10 +124,14 @@ public:
state(QPrinter::Idle),
resolution(0),
m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))),
stretch_x(1), stretch_y(1), origin_x(0), origin_y(0),
dpi_x(96), dpi_y(96), dpi_display(96),
num_copies(1),
printToFile(false),
reinit(false),
embed_fonts(true)
complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false),
embed_fonts(true),
txop(0 /* QTransform::TxNone */)
{
}