summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2017-06-17 14:01:36 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-17 15:43:38 +0200
commit6149da20ddee5c0c50b445fb6a4e3e81b5ff900b (patch)
tree7cfca9c16dff522f0c0e15809f9fe4b926078698 /unotools
parent470752f50c146b449b1c9bdccc36ed031535663c (diff)
replace misc double checked locking patterns
... with thread safe local statics Change-Id: Ie3c8023776a388846b989f00a0be185273c0d5da Reviewed-on: https://gerrit.libreoffice.org/38907 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/syslocaleoptions.cxx19
-rw-r--r--unotools/source/misc/syslocale.cxx19
2 files changed, 12 insertions, 26 deletions
diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx
index 1bfb1be81109..ed1675ffaed1 100644
--- a/unotools/source/config/syslocaleoptions.cxx
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -523,19 +523,12 @@ SvtSysLocaleOptions::~SvtSysLocaleOptions()
// static
Mutex& SvtSysLocaleOptions::GetMutex()
{
- static Mutex* pMutex = nullptr;
- if( !pMutex )
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if( !pMutex )
- {
- // #i77768# Due to a static reference in the toolkit lib
- // we need a mutex that lives longer than the svl library.
- // Otherwise the dtor would use a destructed mutex!!
- pMutex = new Mutex;
- }
- }
- return *pMutex;
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svl library.
+ // Otherwise the dtor would use a destructed mutex!!
+ static Mutex persistentMutex;
+
+ return persistentMutex;
}
bool SvtSysLocaleOptions::IsModified()
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index 0955090391a2..0dcecca29392 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -134,19 +134,12 @@ SvtSysLocale::~SvtSysLocale()
// static
Mutex& SvtSysLocale::GetMutex()
{
- static Mutex* pMutex = nullptr;
- if( !pMutex )
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if( !pMutex )
- {
- // #i77768# Due to a static reference in the toolkit lib
- // we need a mutex that lives longer than the svl library.
- // Otherwise the dtor would use a destructed mutex!!
- pMutex = new Mutex;
- }
- }
- return *pMutex;
+ // #i77768# Due to a static reference in the toolkit lib
+ // we need a mutex that lives longer than the svl library.
+ // Otherwise the dtor would use a destructed mutex!!
+ static Mutex persistentMutex;
+
+ return persistentMutex;
}
const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const