From 0ace1802a1a5a01e4c64dbf6b9ee6e090ddaa49f Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 25 Jul 2024 09:55:24 +0200 Subject: [PATCH] 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 --- src/plugins/coreplugin/icore.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 283c584fa2a..169c8dffd33 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -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,