summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-11 13:04:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-11 21:13:48 +0200
commitc8e144638c10f81a25478dd8d8061d7d870b383c (patch)
tree66ea946b0462a0f5cdf3475a8661580dc9dc9eca /unotools
parentbed301f42f0e51126c63c02c9a78091f7dec420c (diff)
osl::Mutex->std::mutex in SvtSysLocale
Change-Id: I722c4ca5d1bb6c0de6b1eff7478de03a23e9d89b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134199 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/misc/syslocale.cxx30
1 files changed, 16 insertions, 14 deletions
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index 889d9b34688f..954e7e94caf8 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -31,6 +31,7 @@
#include <osl/nlsupport.h>
#include <memory>
+#include <mutex>
#include <optional>
#include <vector>
@@ -41,6 +42,18 @@ namespace {
std::weak_ptr<SvtSysLocale_Impl> g_pSysLocale;
+// static
+std::mutex& GetMutex()
+{
+ // #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 std::mutex* persistentMutex(new std::mutex);
+
+ return *persistentMutex;
+}
+
+
}
class SvtSysLocale_Impl : public utl::ConfigurationListener
@@ -88,7 +101,7 @@ void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, Co
!(nHint & ConfigurationHints::DatePatterns) )
return;
- MutexGuard aGuard( SvtSysLocale::GetMutex() );
+ std::unique_lock aGuard( GetMutex() );
const LanguageTag& rLanguageTag = aSysLocaleOptions.GetRealLanguageTag();
if ( nHint & ConfigurationHints::Locale )
@@ -115,7 +128,7 @@ std::vector<OUString> SvtSysLocale_Impl::getDateAcceptancePatternsConfig() const
SvtSysLocale::SvtSysLocale()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock aGuard( GetMutex() );
pImpl = g_pSysLocale.lock();
if ( !pImpl )
{
@@ -126,21 +139,10 @@ SvtSysLocale::SvtSysLocale()
SvtSysLocale::~SvtSysLocale()
{
- MutexGuard aGuard( GetMutex() );
+ std::unique_lock aGuard( GetMutex() );
pImpl.reset();
}
-// static
-Mutex& SvtSysLocale::GetMutex()
-{
- // #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(new Mutex);
-
- return *persistentMutex;
-}
-
const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const
{
return *(pImpl->pLocaleData);