diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-10 16:14:56 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-05-20 15:23:38 +0100 |
commit | a1e2078b24132f086e94b85bf7a07d69ab191120 (patch) | |
tree | c46d441fa73c4f746a4ab906d07e414ec922c2cc | |
parent | 93a28b0aced7f552f0f072c795f4301a2bad0d0e (diff) |
config leaks: make this a well behaved singleton
-rw-r--r-- | svtools/inc/svtools/htmlcfg.hxx | 6 | ||||
-rw-r--r-- | svtools/source/config/htmlcfg.cxx | 14 |
2 files changed, 11 insertions, 9 deletions
diff --git a/svtools/inc/svtools/htmlcfg.hxx b/svtools/inc/svtools/htmlcfg.hxx index 33c87839db8a..c668324069bd 100644 --- a/svtools/inc/svtools/htmlcfg.hxx +++ b/svtools/inc/svtools/htmlcfg.hxx @@ -59,8 +59,8 @@ class SVT_DLLPUBLIC SvxHtmlOptions : public utl::ConfigItem void CallListeners(); public: - SvxHtmlOptions(); - ~SvxHtmlOptions(); + SvxHtmlOptions(); + ~SvxHtmlOptions(); virtual void Commit(); virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames); @@ -92,7 +92,7 @@ public: sal_Bool IsDefaultTextEncoding() const; rtl_TextEncoding GetTextEncoding() const; void SetTextEncoding( rtl_TextEncoding ); - static SvxHtmlOptions* Get(); + static SvxHtmlOptions& Get(); sal_Bool IsNumbersEnglishUS() const; void SetNumbersEnglishUS(sal_Bool bSet); diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx index c3d5526a41fa..338fd0d6e40c 100644 --- a/svtools/source/config/htmlcfg.cxx +++ b/svtools/source/config/htmlcfg.cxx @@ -35,6 +35,7 @@ #include <tools/debug.hxx> #include <tools/link.hxx> #include <sal/macros.h> +#include <rtl/instance.hxx> #include <list> // ----------------------------------------------------------------------- @@ -53,8 +54,6 @@ using namespace com::sun::star::uno; using ::rtl::OUString; -static SvxHtmlOptions* pOptions = 0; - #define C2U(cChar) OUString::createFromAscii(cChar) struct HtmlOptions_Impl @@ -458,11 +457,14 @@ sal_Bool SvxHtmlOptions::IsDefaultTextEncoding() const return pImp->bIsEncodingDefault; } -SvxHtmlOptions* SvxHtmlOptions::Get() +namespace +{ + class theSvxHtmlOptions : public rtl::Static<SvxHtmlOptions, theSvxHtmlOptions> {}; +} + +SvxHtmlOptions& SvxHtmlOptions::Get() { - if ( !pOptions ) - pOptions = new SvxHtmlOptions; - return pOptions; + return theSvxHtmlOptions::get(); } sal_Bool SvxHtmlOptions::IsNumbersEnglishUS() const |