summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svtools/source/config/optionsdrawinglayer.cxx24
-rw-r--r--unotools/source/config/cacheoptions.cxx25
-rw-r--r--unotools/source/config/cmdoptions.cxx25
-rw-r--r--unotools/source/config/compatibility.cxx24
-rw-r--r--unotools/source/config/dynamicmenuoptions.cxx24
-rw-r--r--unotools/source/config/eventcfg.cxx26
-rw-r--r--unotools/source/config/extendedsecurityoptions.cxx24
-rw-r--r--unotools/source/config/fontoptions.cxx25
-rw-r--r--unotools/source/config/historyoptions.cxx24
-rw-r--r--unotools/source/config/internaloptions.cxx24
-rw-r--r--unotools/source/config/localisationoptions.cxx24
-rw-r--r--unotools/source/config/moduleoptions.cxx24
-rw-r--r--unotools/source/config/optionsdlg.cxx18
-rw-r--r--unotools/source/config/printwarningoptions.cxx24
-rw-r--r--unotools/source/config/regoptions.cxx18
-rw-r--r--unotools/source/config/securityoptions.cxx24
-rw-r--r--unotools/source/config/startoptions.cxx24
-rw-r--r--unotools/source/config/useroptions.cxx25
-rw-r--r--unotools/source/config/viewoptions.cxx24
-rw-r--r--unotools/source/config/workingsetoptions.cxx24
20 files changed, 124 insertions, 350 deletions
diff --git a/svtools/source/config/optionsdrawinglayer.cxx b/svtools/source/config/optionsdrawinglayer.cxx
index 546212bebc45..88349a8b1b8f 100644
--- a/svtools/source/config/optionsdrawinglayer.cxx
+++ b/svtools/source/config/optionsdrawinglayer.cxx
@@ -1685,29 +1685,17 @@ void SvtOptionsDrawinglayer::SetSelectionMaximumLuminancePercent( sal_uInt16 nPe
m_pDataContainer->SetSelectionMaximumLuminancePercent( nPercent );
}
+namespace
+{
+ class theOptionsDrawinglayerMutex : public rtl::Static<osl::Mutex, theOptionsDrawinglayerMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtOptionsDrawinglayer::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theOptionsDrawinglayerMutex::get();
}
// eof
diff --git a/unotools/source/config/cacheoptions.cxx b/unotools/source/config/cacheoptions.cxx
index 45f0850e8969..a7dc14b6845b 100644
--- a/unotools/source/config/cacheoptions.cxx
+++ b/unotools/source/config/cacheoptions.cxx
@@ -32,6 +32,7 @@
#include <unotools/cacheoptions.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/configitem.hxx>
+#include <rtl/instance.hxx>
#include <tools/debug.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
@@ -481,29 +482,17 @@ void SvtCacheOptions::SetGraphicManagerObjectReleaseTime( sal_Int32 nGrfMgrObjec
m_pDataContainer->SetGraphicManagerObjectReleaseTime( nGrfMgrObjectReleaseTime );
}
+namespace
+{
+ class theCacheOptionsMutex : public rtl::Static<osl::Mutex, theCacheOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtCacheOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theCacheOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx
index b17771cb4369..c110148c069f 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -42,6 +42,7 @@
#include <cppuhelper/weakref.hxx>
#include <tools/urlobj.hxx>
#include <rtl/ustrbuf.hxx>
+#include <rtl/instance.hxx>
#include <itemholder1.hxx>
@@ -593,29 +594,17 @@ void SvtCommandOptions::EstablisFrameCallback(const ::com::sun::star::uno::Refer
m_pDataContainer->EstablisFrameCallback(xFrame);
}
+namespace
+{
+ class theCommandOptionsMutex : public rtl::Static<osl::Mutex, theCommandOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtCommandOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theCommandOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index 275230452919..6a5087089490 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -817,29 +817,17 @@ Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions::GetList() const
return m_pDataContainer->GetList();
}
+namespace
+{
+ class theCompatibilityOptionsMutex : public rtl::Static<osl::Mutex, theCompatibilityOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtCompatibilityOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theCompatibilityOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx
index 76950ee441bc..ec80822b4d65 100644
--- a/unotools/source/config/dynamicmenuoptions.cxx
+++ b/unotools/source/config/dynamicmenuoptions.cxx
@@ -887,29 +887,17 @@ void SvtDynamicMenuOptions::AppendItem( EDynamicMenuType eMenu
m_pDataContainer->AppendItem( eMenu, sURL, sTitle, sImageIdentifier, sTargetName );
}
+namespace
+{
+ class theDynamicMenuOptionsMutex : public rtl::Static<osl::Mutex, theDynamicMenuOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtDynamicMenuOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theDynamicMenuOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index a1dbcda74e0b..a6de56a6a5d6 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -423,28 +423,14 @@ sal_Bool SAL_CALL GlobalEventConfig::hasElements( ) throw (RuntimeException)
return m_pImpl->hasElements( );
}
+namespace
+{
+ class theGlobalEventConfigMutex : public rtl::Static<osl::Mutex, theGlobalEventConfigMutex>{};
+}
+
Mutex& GlobalEventConfig::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect following code with
- // the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that
- // another instance of our class will be faster then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theGlobalEventConfigMutex::get();
}
::rtl::OUString GlobalEventConfig::GetEventName( sal_Int32 nIndex )
diff --git a/unotools/source/config/extendedsecurityoptions.cxx b/unotools/source/config/extendedsecurityoptions.cxx
index d64958b15b4e..fe5cc90d28cb 100644
--- a/unotools/source/config/extendedsecurityoptions.cxx
+++ b/unotools/source/config/extendedsecurityoptions.cxx
@@ -509,29 +509,17 @@ void SvtExtendedSecurityOptions::SetOpenHyperlinkMode( SvtExtendedSecurityOption
m_pDataContainer->SetOpenHyperlinkMode( eMode );
}
+namespace
+{
+ class theExtendedSecurityOptionsMutex : public rtl::Static<osl::Mutex, theExtendedSecurityOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtExtendedSecurityOptions::GetInitMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theExtendedSecurityOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/fontoptions.cxx b/unotools/source/config/fontoptions.cxx
index 13126e5612b9..9cb8a1831e97 100644
--- a/unotools/source/config/fontoptions.cxx
+++ b/unotools/source/config/fontoptions.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/logfile.hxx>
+#include <rtl/instance.hxx>
#include "itemholder1.hxx"
//_________________________________________________________________________________________________________________
@@ -480,29 +481,17 @@ void SvtFontOptions::EnableFontWYSIWYG( sal_Bool bState )
m_pDataContainer->EnableFontWYSIWYG( bState );
}
+namespace
+{
+ class theFontOptionsMutex : public rtl::Static<osl::Mutex, theFontOptionsMutex> {};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtFontOptions::impl_GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theFontOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 7cc8d4eedefd..d6990fb40fa8 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -699,29 +699,17 @@ void SvtHistoryOptions::AppendItem( EHistoryType eHistory ,
m_pDataContainer->AppendItem( eHistory, sURL, sFilter, sTitle, sPassword );
}
+namespace
+{
+ class theHistoryOptionsMutex : public rtl::Static<osl::Mutex, theHistoryOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtHistoryOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theHistoryOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/internaloptions.cxx b/unotools/source/config/internaloptions.cxx
index d1501a612128..63f4827c760c 100644
--- a/unotools/source/config/internaloptions.cxx
+++ b/unotools/source/config/internaloptions.cxx
@@ -560,29 +560,17 @@ void SvtInternalOptions::SetCurrentTempURL( const OUString& aNewCurrentTempURL )
m_pDataContainer->SetCurrentTempURL( aNewCurrentTempURL );
}
+namespace
+{
+ class theInternalOptionsMutex : public rtl::Static<osl::Mutex, theInternalOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtInternalOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theInternalOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/localisationoptions.cxx b/unotools/source/config/localisationoptions.cxx
index 3f7713e3b854..d3392ea6cc92 100644
--- a/unotools/source/config/localisationoptions.cxx
+++ b/unotools/source/config/localisationoptions.cxx
@@ -427,29 +427,17 @@ void SvtLocalisationOptions::SetDialogScale( sal_Int32 nScale )
m_pDataContainer->SetDialogScale( nScale );
}
+namespace
+{
+ class theLocalisationOptionsMutex : public rtl::Static<osl::Mutex, theLocalisationOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtLocalisationOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theLocalisationOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx
index 4edb4fb0968e..c275a910510e 100644
--- a/unotools/source/config/moduleoptions.cxx
+++ b/unotools/source/config/moduleoptions.cxx
@@ -38,6 +38,7 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
+#include <rtl/instance.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -1278,6 +1279,10 @@ sal_uInt32 SvtModuleOptions::GetFeatures() const
return nFeature;
}
+namespace
+{
+ class theModuleOptionsMutex : public rtl::Static<osl::Mutex, theModuleOptionsMutex> {};
+}
/*-****************************************************************************************************//**
@short return a reference to a static mutex
@descr These class is threadsafe.
@@ -1294,24 +1299,7 @@ sal_uInt32 SvtModuleOptions::GetFeatures() const
*//*-*****************************************************************************************************/
::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static ::osl::Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static ::osl::Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theModuleOptionsMutex::get();
}
::rtl::OUString SvtModuleOptions::GetModuleName( EModule eModule ) const
diff --git a/unotools/source/config/optionsdlg.cxx b/unotools/source/config/optionsdlg.cxx
index c8a12c088804..4aeb603a6717 100644
--- a/unotools/source/config/optionsdlg.cxx
+++ b/unotools/source/config/optionsdlg.cxx
@@ -92,20 +92,14 @@ public:
const OUString& _rGroup ) const;
};
-::osl::Mutex & SvtOptionsDlgOptions_Impl::getInitMutex()
+namespace
{
- static ::osl::Mutex *pMutex = 0;
+ class theOptionsDlgOptions_ImplMutex : public rtl::Static<osl::Mutex, theOptionsDlgOptions_ImplMutex>{};
+}
- if( ! pMutex )
- {
- ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
- if( ! pMutex )
- {
- static ::osl::Mutex mutex;
- pMutex = &mutex;
- }
- }
- return *pMutex;
+::osl::Mutex & SvtOptionsDlgOptions_Impl::getInitMutex()
+{
+ return theOptionsDlgOptions_ImplMutex::get();
}
// -----------------------------------------------------------------------
diff --git a/unotools/source/config/printwarningoptions.cxx b/unotools/source/config/printwarningoptions.cxx
index 6f867c6b669c..11b656334454 100644
--- a/unotools/source/config/printwarningoptions.cxx
+++ b/unotools/source/config/printwarningoptions.cxx
@@ -390,29 +390,17 @@ void SvtPrintWarningOptions::SetModifyDocumentOnPrintingAllowed( sal_Bool bState
m_pDataContainer->SetModifyDocumentOnPrintingAllowed( bState ) ;
}
+namespace
+{
+ class thePrintWarningOptionsMutex : public rtl::Static<osl::Mutex, thePrintWarningOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtPrintWarningOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return thePrintWarningOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/regoptions.cxx b/unotools/source/config/regoptions.cxx
index fcd4c767ef8a..9b0550a8cdc5 100644
--- a/unotools/source/config/regoptions.cxx
+++ b/unotools/source/config/regoptions.cxx
@@ -35,6 +35,7 @@
#include <osl/mutex.hxx>
#include <unotools/bootstrap.hxx>
#include <rtl/ustring.hxx>
+#include <rtl/instance.hxx>
//........................................................................
namespace utl
@@ -196,20 +197,15 @@ namespace utl
sal_Bool RegOptionsImpl::s_bThisSessionDone = sal_False;
sal_Int32 RegOptionsImpl::s_nInstanceCount = 0;
+ namespace
+ {
+ class theRegOptionsImplMutex : public rtl::Static<osl::Mutex, theRegOptionsImplMutex>{};
+ }
+
//--------------------------------------------------------------------
::osl::Mutex& RegOptionsImpl::getStaticMutex()
{
- static ::osl::Mutex* s_pStaticMutex = NULL;
- if ( !s_pStaticMutex )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if ( !s_pStaticMutex )
- {
- static ::osl::Mutex s_aStaticMutex;
- s_pStaticMutex = &s_aStaticMutex;
- }
- }
- return *s_pStaticMutex;
+ return theRegOptionsImplMutex::get();
}
//--------------------------------------------------------------------
diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx
index fb0ea146b71c..21914d1a402f 100644
--- a/unotools/source/config/securityoptions.cxx
+++ b/unotools/source/config/securityoptions.cxx
@@ -1166,26 +1166,14 @@ bool SvtSecurityOptions::IsOptionEnabled( EOption eOption ) const
return m_pDataContainer->IsOptionEnabled( eOption );
}
+namespace
+{
+ class theSecurityOptionsMutex : public rtl::Static<osl::Mutex, theSecurityOptionsMutex>{};
+}
+
Mutex& SvtSecurityOptions::GetInitMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be faster then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theSecurityOptionsMutex::get();
}
diff --git a/unotools/source/config/startoptions.cxx b/unotools/source/config/startoptions.cxx
index 98d17b9a739b..c47b34946dd3 100644
--- a/unotools/source/config/startoptions.cxx
+++ b/unotools/source/config/startoptions.cxx
@@ -427,29 +427,17 @@ void SvtStartOptions::SetConnectionURL( const OUString& sURL )
m_pDataContainer->SetConnectionURL( sURL );
}
+namespace
+{
+ class theStartOptionsMutex : public rtl::Static<osl::Mutex, theStartOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtStartOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theStartOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index ee88691535a2..11a781213b4c 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -985,27 +985,14 @@ SvtUserOptions::~SvtUserOptions()
// -----------------------------------------------------------------------
+namespace
+{
+ class theUserOptionsMutex : public rtl::Static<osl::Mutex, theUserOptionsMutex>{};
+}
+
::osl::Mutex& SvtUserOptions::GetInitMutex()
{
- // Initialize static mutex only for one time!
- static ::osl::Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if ( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- // We must check our pointer again -
- // because another instance of our class will be faster then this instance!
- if ( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static ::osl::Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theUserOptionsMutex::get();
}
// -----------------------------------------------------------------------
diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx
index c0eecd9e7edd..9fe4aba17ed7 100644
--- a/unotools/source/config/viewoptions.cxx
+++ b/unotools/source/config/viewoptions.cxx
@@ -1225,29 +1225,17 @@ void SvtViewOptions::SetUserItem( const ::rtl::OUString& sName ,
}
}
+namespace
+{
+ class theViewOptionsMutex : public rtl::Static<osl::Mutex, theViewOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
::osl::Mutex& SvtViewOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static ::osl::Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static ::osl::Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theViewOptionsMutex::get();
}
void SvtViewOptions::AcquireOptions()
diff --git a/unotools/source/config/workingsetoptions.cxx b/unotools/source/config/workingsetoptions.cxx
index fd498c7b7556..39f2ebef773d 100644
--- a/unotools/source/config/workingsetoptions.cxx
+++ b/unotools/source/config/workingsetoptions.cxx
@@ -362,29 +362,17 @@ void SvtWorkingSetOptions::SetWindowList( const Sequence< OUString >& seqWindowL
m_pDataContainer->SetWindowList( seqWindowList );
}
+namespace
+{
+ class theWorkingSetOptionsMutex : public rtl::Static<osl::Mutex, theWorkingSetOptionsMutex>{};
+}
+
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
Mutex& SvtWorkingSetOptions::GetOwnStaticMutex()
{
- // Initialize static mutex only for one time!
- static Mutex* pMutex = NULL;
- // If these method first called (Mutex not already exist!) ...
- if( pMutex == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
- if( pMutex == NULL )
- {
- // Create the new mutex and set it for return on static variable.
- static Mutex aMutex;
- pMutex = &aMutex;
- }
- }
- // Return new created or already existing mutex object.
- return *pMutex;
+ return theWorkingSetOptionsMutex::get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */