From 4bcd8fc2dee683da632466e6de5d782f52263951 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 19 Mar 2012 15:31:17 +0200 Subject: Fix infinite recursion crash in QPrinterInfo::supportedPaperSizes() This function calls platform specific function QWindowsPrinterSupport::supportedPaperSizes(), which then called back to QPrinterInfo::supportedPaperSizes(), causing infinite recursion. Fixed by providing a proper implementation for querying supported paper sizes in QWin32PrintEngine - the same implementation was used in Qt 4.8. Task-number: QTBUG-24190 Change-Id: I64a2773d83596df19818bf2636f1255943d7851d Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprintengine_win.cpp | 20 ++++++++++++++++++++ src/printsupport/kernel/qprintengine_win_p.h | 3 +++ 2 files changed, 23 insertions(+) (limited to 'src/printsupport/kernel') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index e209314fbc..171ebbce17 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1581,6 +1581,26 @@ void QWin32PrintEngine::releaseDC(HDC) const } +QList QWin32PrintEngine::supportedPaperSizes(const QPrinterInfo &printerInfo) +{ + QList returnList; + + if (printerInfo.isNull()) + return returnList; + + DWORD size = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERS, NULL, NULL); + if ((int)size != -1) { + wchar_t *papers = new wchar_t[size]; + size = DeviceCapabilities(reinterpret_cast(printerInfo.printerName().utf16()), + NULL, DC_PAPERS, papers, NULL); + for (int c = 0; c < (int)size; ++c) + returnList.append(mapDevmodePaperSize(papers[c])); + delete [] papers; + } + return returnList; +} + HGLOBAL *QWin32PrintEnginePrivate::createDevNames() { int size = sizeof(DEVNAMES) diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h index baf8ccefce..c267c1057f 100644 --- a/src/printsupport/kernel/qprintengine_win_p.h +++ b/src/printsupport/kernel/qprintengine_win_p.h @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -105,6 +106,8 @@ public: HDC getPrinterDC() const { return getDC(); } void releasePrinterDC(HDC dc) const { releaseDC(dc); } + static QList supportedPaperSizes(const QPrinterInfo &printerInfo); + private: friend class QPrintDialog; friend class QPageSetupDialog; -- cgit v1.2.3