From e9a467cafbffb380c54e90b24f9ee20cd4adc7e8 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 2 Apr 2012 09:38:26 +0100 Subject: remove static objects from static_initialization_and_destruction chain --- formula/source/core/inc/core_resource.hxx | 1 - formula/source/core/resource/core_resource.cxx | 11 ++++++++--- formula/source/ui/inc/ModuleHelper.hxx | 1 - formula/source/ui/resource/ModuleHelper.cxx | 13 +++++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) (limited to 'formula') diff --git a/formula/source/core/inc/core_resource.hxx b/formula/source/core/inc/core_resource.hxx index 6dc198d90141..a78fc3937d39 100644 --- a/formula/source/core/inc/core_resource.hxx +++ b/formula/source/core/inc/core_resource.hxx @@ -43,7 +43,6 @@ namespace formula class ResourceManager { friend class OModuleClient; - static ::osl::Mutex s_aMutex; /// access safety static sal_Int32 s_nClients; /// number of registered clients static ResMgr* m_pImpl; diff --git a/formula/source/core/resource/core_resource.cxx b/formula/source/core/resource/core_resource.cxx index 9521db87c119..e0c31a6b52e3 100644 --- a/formula/source/core/resource/core_resource.cxx +++ b/formula/source/core/resource/core_resource.cxx @@ -32,6 +32,7 @@ // ---- needed as long as we have no contexts for components --- #include +#include #include //......................................................................... @@ -41,7 +42,11 @@ namespace formula //================================================================== //= ResourceManager //================================================================== - ::osl::Mutex ResourceManager::s_aMutex; + namespace + { + // access safety + struct theResourceManagerMutex : public rtl::Static< osl::Mutex, theResourceManagerMutex > {}; + } sal_Int32 ResourceManager::s_nClients = 0; ResMgr* ResourceManager::m_pImpl = NULL; @@ -59,14 +64,14 @@ namespace formula //------------------------------------------------------------------------- void ResourceManager::registerClient() { - ::osl::MutexGuard aGuard(s_aMutex); + ::osl::MutexGuard aGuard(theResourceManagerMutex::get()); ++s_nClients; } //------------------------------------------------------------------------- void ResourceManager::revokeClient() { - ::osl::MutexGuard aGuard(s_aMutex); + ::osl::MutexGuard aGuard(theResourceManagerMutex::get()); if (!--s_nClients && m_pImpl) { delete m_pImpl; diff --git a/formula/source/ui/inc/ModuleHelper.hxx b/formula/source/ui/inc/ModuleHelper.hxx index 6599c389bf99..80944de8e613 100644 --- a/formula/source/ui/inc/ModuleHelper.hxx +++ b/formula/source/ui/inc/ModuleHelper.hxx @@ -49,7 +49,6 @@ namespace formula // not implemented. OModule is a static class protected: - static ::osl::Mutex s_aMutex; /// access safety static sal_Int32 s_nClients; /// number of registered clients static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered diff --git a/formula/source/ui/resource/ModuleHelper.cxx b/formula/source/ui/resource/ModuleHelper.cxx index a0c2ae61f859..f30f58821604 100644 --- a/formula/source/ui/resource/ModuleHelper.cxx +++ b/formula/source/ui/resource/ModuleHelper.cxx @@ -32,13 +32,14 @@ #include #include #include +#include #include #include #include #define EXPAND_PROTOCOL "vnd.sun.star.expand:" #define ENTER_MOD_METHOD() \ - ::osl::MutexGuard aGuard(s_aMutex); \ + ::osl::MutexGuard aGuard(theOModuleMutex::get()); \ ensureImpl() //......................................................................... @@ -98,7 +99,11 @@ ResMgr* OModuleImpl::getResManager() //========================================================================= //= OModule //========================================================================= -::osl::Mutex OModule::s_aMutex; +namespace +{ + // access safety + struct theOModuleMutex : public rtl::Static< osl::Mutex, theOModuleMutex > {}; +} sal_Int32 OModule::s_nClients = 0; OModuleImpl* OModule::s_pImpl = NULL; //------------------------------------------------------------------------- @@ -111,14 +116,14 @@ ResMgr* OModule::getResManager() //------------------------------------------------------------------------- void OModule::registerClient() { - ::osl::MutexGuard aGuard(s_aMutex); + ::osl::MutexGuard aGuard(theOModuleMutex::get()); ++s_nClients; } //------------------------------------------------------------------------- void OModule::revokeClient() { - ::osl::MutexGuard aGuard(s_aMutex); + ::osl::MutexGuard aGuard(theOModuleMutex::get()); if (!--s_nClients && s_pImpl) { delete s_pImpl; -- cgit