diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-30 15:30:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-06-01 15:21:18 +0100 |
commit | 5a3c6e0a3dc07b09352203cccdae8bf60649f487 (patch) | |
tree | f403063b13fb4f2c758beb59638d8b9d633bdce4 /configmgr/source/components.cxx | |
parent | 205540afc1ab05763a8255873724bcbdbf9c0ba2 (diff) |
use StaticWithArg
Diffstat (limited to 'configmgr/source/components.cxx')
-rw-r--r-- | configmgr/source/components.cxx | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 8760946020f5..d4b3130ca9ed 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -57,6 +57,7 @@ #include "rtl/textenc.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" +#include "rtl/instance.hxx" #include "sal/types.h" #include "salhelper/simplereferenceobject.hxx" @@ -150,9 +151,6 @@ bool canRemoveFromLayer(int layer, rtl::Reference< Node > const & node) { } } -static bool singletonCreated = false; -static Components * singleton = 0; - } class Components::WriteThread: @@ -217,23 +215,19 @@ void Components::WriteThread::run() { reference_->clear(); } +class theComponentsSingleton : + public rtl::StaticWithArg< + Components, + css::uno::Reference< css::uno::XComponentContext >, + theComponentsSingleton> +{ +}; + Components & Components::getSingleton( css::uno::Reference< css::uno::XComponentContext > const & context) { OSL_ASSERT(context.is()); - if (!singletonCreated) { - static Components theSingleton(context); - singleton = &theSingleton; - singletonCreated = true; - } - if (singleton == 0) { - throw css::uno::RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "configmgr no Components singleton")), - css::uno::Reference< css::uno::XInterface >()); - } - return *singleton; + return theComponentsSingleton::get(context); } bool Components::allLocales(rtl::OUString const & locale) { |