diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2012-03-19 15:31:17 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-19 18:02:39 +0100 |
commit | 4bcd8fc2dee683da632466e6de5d782f52263951 (patch) | |
tree | dd61d751af0f32130e9941904be5e0caee9e81b7 /src/printsupport/kernel/qprintengine_win.cpp | |
parent | 2d5a4a5d3aae4efe7c17cadf03dfbb5cc4c36e86 (diff) |
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 <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/printsupport/kernel/qprintengine_win.cpp')
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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<QPrinter::PaperSize> QWin32PrintEngine::supportedPaperSizes(const QPrinterInfo &printerInfo) +{ + QList<QPrinter::PaperSize> returnList; + + if (printerInfo.isNull()) + return returnList; + + DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t *>(printerInfo.printerName().utf16()), + NULL, DC_PAPERS, NULL, NULL); + if ((int)size != -1) { + wchar_t *papers = new wchar_t[size]; + size = DeviceCapabilities(reinterpret_cast<const wchar_t *>(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) |