When the print panel was closed then it would clean up the printinfo
and if it was requested for the same QPrinter then it would not be
recreated in time. Therefore we check if it is initalized and if not
we re-initalize it.
Task-number: QTBUG-28657
Change-Id: I7dc9011b80e03cfa3eae8fee2fcf6cc8021a8566
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
(cherry picked from commit
dde9569d389b4382e8869ac48f942adb3c51ade7)
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
{
#ifndef QT_NO_WIDGETS
- QMacPrintEngine *macPrintEngine = static_cast<QMacPrintEngine *>(printEngine);
- return macPrintEngine->d_func()->printInfo;
+ QMacPrintEnginePrivate *macPrintEnginePriv = static_cast<QMacPrintEngine *>(printEngine)->d_func();
+ if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized())
+ macPrintEnginePriv->initialize();
+ return macPrintEnginePriv->printInfo;
#else
qFatal("Printing is not supported when Qt is configured with -no-widgets");
return 0;