From 43c80a7f3d338ef28b9d4a94415ca72acccbd8dc Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 28 Oct 2010 16:37:27 +0200 Subject: sb132: #i114877# combined configmgr::Components::{init,get}Singleton --- configmgr/source/components.cxx | 6 +----- configmgr/source/components.hxx | 4 +--- configmgr/source/configurationprovider.cxx | 6 ++---- configmgr/source/update.cxx | 30 +++++++++++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 32478e9681..2d148959ed 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -214,7 +214,7 @@ void Components::WriteThread::run() { reference_->clear(); } -void Components::initSingleton( +Components & Components::getSingleton( css::uno::Reference< css::uno::XComponentContext > const & context) { OSL_ASSERT(context.is()); @@ -223,10 +223,6 @@ void Components::initSingleton( static Components theSingleton(context); singleton = &theSingleton; } -} - -Components & Components::getSingleton() { - OSL_ASSERT(singletonCreated); if (singleton == 0) { throw css::uno::RuntimeException( rtl::OUString( diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index 1c735efca6..34b693c7e5 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -65,12 +65,10 @@ class RootAccess; class Components: private boost::noncopyable { public: - static void initSingleton( + static Components & getSingleton( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context); - static Components & getSingleton(); - static bool allLocales(rtl::OUString const & locale); rtl::Reference< Node > resolvePathRepresentation( diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx index d636737a29..999253118f 100644 --- a/configmgr/source/configurationprovider.cxx +++ b/configmgr/source/configurationprovider.cxx @@ -275,8 +275,7 @@ Service::createInstanceWithArguments( static_cast< cppu::OWeakObject * >(this)); } osl::MutexGuard guard(lock); - Components::initSingleton(context_); - Components & components = Components::getSingleton(); + Components & components = Components::getSingleton(context_); rtl::Reference< RootAccess > root( new RootAccess(components, nodepath, locale, update)); if (root->isValue()) { @@ -387,8 +386,7 @@ void Service::flushModifications() const { Components * components; { osl::MutexGuard guard(lock); - Components::initSingleton(context_); - components = &Components::getSingleton(); + components = &Components::getSingleton(context_); } components->flushModifications(); } diff --git a/configmgr/source/update.cxx b/configmgr/source/update.cxx index 73074aa7c3..258765158a 100644 --- a/configmgr/source/update.cxx +++ b/configmgr/source/update.cxx @@ -71,7 +71,11 @@ class Service: private boost::noncopyable { public: - Service() {} + Service(css::uno::Reference< css::uno::XComponentContext > const context): + context_(context) + { + OSL_ASSERT(context.is()); + } private: virtual ~Service() {} @@ -92,6 +96,8 @@ private: css::uno::Sequence< rtl::OUString > const & includedPaths, css::uno::Sequence< rtl::OUString > const & excludedPaths) throw (css::uno::RuntimeException); + + css::uno::Reference< css::uno::XComponentContext > context_; }; void Service::insertExtensionXcsFile( @@ -99,7 +105,7 @@ void Service::insertExtensionXcsFile( throw (css::uno::RuntimeException) { osl::MutexGuard g(lock); - Components::getSingleton().insertExtensionXcsFile(shared, fileUri); + Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri); } void Service::insertExtensionXcuFile( @@ -109,10 +115,10 @@ void Service::insertExtensionXcuFile( Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().insertExtensionXcuFile( - shared, fileUri, &mods); - Components::getSingleton().initGlobalBroadcaster( + components.insertExtensionXcuFile(shared, fileUri, &mods); + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -124,9 +130,10 @@ void Service::removeExtensionXcuFile(rtl::OUString const & fileUri) Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().removeExtensionXcuFile(fileUri, &mods); - Components::getSingleton().initGlobalBroadcaster( + components.removeExtensionXcuFile(fileUri, &mods); + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -141,10 +148,11 @@ void Service::insertModificationXcuFile( Broadcaster bc; { osl::MutexGuard g(lock); + Components & components = Components::getSingleton(context_); Modifications mods; - Components::getSingleton().insertModificationXcuFile( + components.insertModificationXcuFile( fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods); - Components::getSingleton().initGlobalBroadcaster( + components.initGlobalBroadcaster( mods, rtl::Reference< RootAccess >(), &bc); } bc.send(); @@ -153,9 +161,9 @@ void Service::insertModificationXcuFile( } css::uno::Reference< css::uno::XInterface > create( - css::uno::Reference< css::uno::XComponentContext > const &) + css::uno::Reference< css::uno::XComponentContext > const & context) { - return static_cast< cppu::OWeakObject * >(new Service); + return static_cast< cppu::OWeakObject * >(new Service(context)); } rtl::OUString getImplementationName() { -- cgit v1.2.3