diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-04-02 09:38:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-04-02 14:53:50 +0100 |
commit | e9a467cafbffb380c54e90b24f9ee20cd4adc7e8 (patch) | |
tree | 9a5c6d4dcfdcb4ff7b089c0219d51e58c70146fc /formula | |
parent | e6409de0f879df204de7b07117798e2d77235458 (diff) |
remove static objects from static_initialization_and_destruction chain
Diffstat (limited to 'formula')
-rw-r--r-- | formula/source/core/inc/core_resource.hxx | 1 | ||||
-rw-r--r-- | formula/source/core/resource/core_resource.cxx | 11 | ||||
-rw-r--r-- | formula/source/ui/inc/ModuleHelper.hxx | 1 | ||||
-rw-r--r-- | formula/source/ui/resource/ModuleHelper.cxx | 13 |
4 files changed, 17 insertions, 9 deletions
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 <vcl/svapp.hxx> +#include <rtl/instance.hxx> #include <svl/solar.hrc> //......................................................................... @@ -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 <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <rtl/instance.hxx> #include <rtl/uri.hxx> #include <tools/debug.hxx> #include <svl/solar.hrc> #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; |