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 | |
parent | WaE: unused return value (diff) | |
download | core-5a3c6e0a3dc07b09352203cccdae8bf60649f487.tar.gz core-5a3c6e0a3dc07b09352203cccdae8bf60649f487.zip |
use StaticWithArg
Diffstat (limited to 'configmgr/source')
-rw-r--r-- | configmgr/source/components.cxx | 26 | ||||
-rw-r--r-- | configmgr/source/components.hxx | 3 | ||||
-rw-r--r-- | configmgr/source/rootaccess.cxx | 3 |
3 files changed, 14 insertions, 18 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) { diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index 9d216e1bb915..26af3fbdecea 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -123,12 +123,13 @@ private: typedef void FileParser( rtl::OUString const &, int, Data &, Partial const *, Modifications *, Additions *); - +public: Components( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context); ~Components(); +private: void parseFileLeniently( FileParser * parseFile, rtl::OUString const & url, int layer, diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx index 90e5675b35a3..f320b999dcd2 100644 --- a/configmgr/source/rootaccess.cxx +++ b/configmgr/source/rootaccess.cxx @@ -130,7 +130,8 @@ bool RootAccess::isUpdate() const { return update_; } -RootAccess::~RootAccess() { +RootAccess::~RootAccess() +{ osl::MutexGuard g(*lock_); getComponents().removeRootAccess(this); } |