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>bb10
parent
2d5a4a5d3a
commit
4bcd8fc2de
|
|
@ -87,15 +87,9 @@ QPaintEngine *QWindowsPrinterSupport::createPaintEngine(QPrintEngine *engine, QP
|
|||
return static_cast<QWin32PrintEngine *>(engine);
|
||||
}
|
||||
|
||||
QList<QPrinter::PaperSize> QWindowsPrinterSupport::supportedPaperSizes(const QPrinterInfo &) const
|
||||
QList<QPrinter::PaperSize> QWindowsPrinterSupport::supportedPaperSizes(const QPrinterInfo &printerInfo) const
|
||||
{
|
||||
QList<QPrinter::PaperSize> returnList;
|
||||
foreach (const QPrinterInfo &info, mPrinterList) {
|
||||
foreach (const QPrinter::PaperSize supportedSize, info.supportedPaperSizes())
|
||||
if (!returnList.contains(supportedSize))
|
||||
returnList.append(supportedSize);
|
||||
}
|
||||
return returnList;
|
||||
return QWin32PrintEngine::supportedPaperSizes(printerInfo);
|
||||
}
|
||||
|
||||
QList<QPrinterInfo> QWindowsPrinterSupport::availablePrinters()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
#include <QtGui/qpaintengine.h>
|
||||
#include <QtPrintSupport/QPrintEngine>
|
||||
#include <QtPrintSupport/QPrinter>
|
||||
#include <QtPrintSupport/QPrinterInfo>
|
||||
#include <private/qpaintengine_alpha_p.h>
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
|
|
@ -105,6 +106,8 @@ public:
|
|||
HDC getPrinterDC() const { return getDC(); }
|
||||
void releasePrinterDC(HDC dc) const { releaseDC(dc); }
|
||||
|
||||
static QList<QPrinter::PaperSize> supportedPaperSizes(const QPrinterInfo &printerInfo);
|
||||
|
||||
private:
|
||||
friend class QPrintDialog;
|
||||
friend class QPageSetupDialog;
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@ QT += printsupport network testlib
|
|||
DEFINES += QT_USE_USING_NAMESPACE
|
||||
|
||||
mac: CONFIG += insignificant_test # QTBUG-23060
|
||||
win32:CONFIG += insignificant_test # QTBUG-24190
|
||||
|
|
|
|||
Loading…
Reference in New Issue