From 63a8d58ef8fa7c59e6aff755e6546e725b513f39 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 16 May 2011 22:26:06 +0100 Subject: non leaky singleton --- unotools/inc/unotools/fontcfg.hxx | 2 +- unotools/source/config/fontcfg.cxx | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'unotools') diff --git a/unotools/inc/unotools/fontcfg.hxx b/unotools/inc/unotools/fontcfg.hxx index 6c2295805afd..136147a095d4 100644 --- a/unotools/inc/unotools/fontcfg.hxx +++ b/unotools/inc/unotools/fontcfg.hxx @@ -97,7 +97,7 @@ class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration public: ~DefaultFontConfiguration(); - static DefaultFontConfiguration* get(); + static DefaultFontConfiguration& get(); rtl::OUString getDefaultFont( const com::sun::star::lang::Locale& rLocale, int nType ) const; rtl::OUString getUserInterfaceFont( const com::sun::star::lang::Locale& rLocale ) const; diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index c3dc28acf079..5786e96af8cc 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -59,8 +59,6 @@ using namespace com::sun::star::container; using ::rtl::OUString; -static DefaultFontConfiguration* mpDefaultFontConfiguration = 0; - /* * DefaultFontConfiguration */ @@ -98,11 +96,10 @@ static const char* getKeyType( int nKeyType ) } } -DefaultFontConfiguration* DefaultFontConfiguration::get() +DefaultFontConfiguration& DefaultFontConfiguration::get() { - if( !mpDefaultFontConfiguration ) - mpDefaultFontConfiguration = new DefaultFontConfiguration(); - return mpDefaultFontConfiguration; + static DefaultFontConfiguration aDefaultFontConfiguration; + return aDefaultFontConfiguration; } DefaultFontConfiguration::DefaultFontConfiguration() -- cgit v1.2.3