Core: Make the global printer a function-static object

QPrinter does not do anything strange in the destructor,
so the change in lifetime is harmless.

Change-Id: Iaa255c8809e977dc480b3e23810f3c11b99fad28
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-07-25 09:55:24 +02:00
parent aaa9e0d8b9
commit 0ace1802a1

View File

@@ -299,7 +299,6 @@ public:
QStringList m_aboutInformation;
Context m_highPrioAdditionalContexts;
Context m_lowPrioAdditionalContexts{Constants::C_GLOBAL};
mutable QPrinter *m_printer = nullptr;
WindowSupport *m_windowSupport = nullptr;
EditorManager *m_editorManager = nullptr;
ExternalToolManager *m_externalToolManager = nullptr;
@@ -580,9 +579,8 @@ QtcSettings *ICore::settings(QSettings::Scope scope)
*/
QPrinter *ICore::printer()
{
if (!d->m_printer)
d->m_printer = new QPrinter(QPrinter::HighResolution);
return d->m_printer;
static QPrinter thePrinter(QPrinter::HighResolution);
return &thePrinter;
}
/*!
@@ -1449,8 +1447,6 @@ ICorePrivate::~ICorePrivate()
delete m_externalToolManager;
m_externalToolManager = nullptr;
MessageManager::destroy();
delete m_printer;
m_printer = nullptr;
delete m_vcsManager;
m_vcsManager = nullptr;
//we need to delete editormanager and statusbarmanager explicitly before the end of the destructor,