diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-09-22 11:20:01 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-09-22 20:42:23 +0200 |
commit | ca8a4c81a4194cfaa526bd8071a2243aad0f3461 (patch) | |
tree | cb22c6d1bbdfa9dff376d85a612ad9ab49db200b /vcl | |
parent | 893c08b59abf31ee0ae50c4ac030b006c43c0976 (diff) |
vcl: [loplugin:badstatics] pManager
Move this to class GenericUnixSalData, which is deleted on shutdown.
Change-Id: I6366c12f255bfeca737b22259c3f58ffa2c6222c
Reviewed-on: https://gerrit.libreoffice.org/42632
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/gendata.hxx | 10 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 24 |
3 files changed, 30 insertions, 8 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index 0dd0cc87b412..47ea4348bdcc 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -45,6 +45,7 @@ class FontSubsetInfo; class FontConfigFontOptions; class FontSelectPattern; +class GenericUnixSalData; namespace psp { class PPDParser; @@ -200,8 +201,9 @@ class VCL_PLUGIN_PUBLIC PrintFontManager DECL_LINK( autoInstallFontLangSupport, Timer*, void ); #endif PrintFontManager(); - ~PrintFontManager(); public: + ~PrintFontManager(); + friend class ::GenericUnixSalData; static PrintFontManager& get(); // one instance only // There may be multiple font ids for font collections diff --git a/vcl/inc/unx/gendata.hxx b/vcl/inc/unx/gendata.hxx index db19b0cf0420..55a9aaf4ba8c 100644 --- a/vcl/inc/unx/gendata.hxx +++ b/vcl/inc/unx/gendata.hxx @@ -14,7 +14,10 @@ #include <saldatabasic.hxx> +#include <memory> + class SalGenericDisplay; +namespace psp { class PrintFontManager; } enum GenericUnixSalDataType { SAL_DATA_GTK, SAL_DATA_GTK3, SAL_DATA_TDE3, SAL_DATA_KDE3, SAL_DATA_KDE4, @@ -31,8 +34,13 @@ class VCL_DLLPUBLIC GenericUnixSalData : public SalData OUString m_aHostname; // for transient storage of unicode strings eg. 'u123' by input methods OUString m_aUnicodeEntry; + + friend class psp::PrintFontManager; + std::unique_ptr<psp::PrintFontManager> m_pPrintFontManager; + public: - GenericUnixSalData( GenericUnixSalDataType t, SalInstance *pInstance ) : SalData(), m_eType( t ), m_pDisplay( nullptr ) { m_pInstance = pInstance; SetSalData( this ); } + GenericUnixSalData(GenericUnixSalDataType const t, SalInstance *const pInstance); + virtual ~GenericUnixSalData() override; virtual void Dispose() {} SalGenericDisplay *GetDisplay() const { return m_pDisplay; } diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index 6726deeefb90..c7ff4c1f5e45 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -30,6 +30,7 @@ #include "impfontcharmap.hxx" #include "svdata.hxx" #include "unx/geninst.h" +#include "unx/gendata.hxx" #include <vcl/strhelper.hxx> #include <vcl/ppdparser.hxx> #include <vcl/embeddedfontshelper.hxx> @@ -111,19 +112,30 @@ PrintFontManager::PrintFont::PrintFont() { } +GenericUnixSalData::GenericUnixSalData(GenericUnixSalDataType const t, SalInstance *const pInstance) + : m_eType(t), m_pDisplay(nullptr), m_pPrintFontManager(nullptr) +{ + m_pInstance = pInstance; SetSalData(this); +} + +GenericUnixSalData::~GenericUnixSalData() +{ +} + /* * one instance only */ PrintFontManager& PrintFontManager::get() { - static PrintFontManager* pManager = nullptr; - if( ! pManager ) + GenericUnixSalData *const pSalData(GetGenericUnixSalData()); + assert(pSalData); + + if (!pSalData->m_pPrintFontManager) { - static PrintFontManager theManager; - pManager = &theManager; - pManager->initialize(); + pSalData->m_pPrintFontManager.reset( new PrintFontManager ); + pSalData->m_pPrintFontManager->initialize(); } - return *pManager; + return *pSalData->m_pPrintFontManager; } /* |