include/unotools/syslocale.hxx     |    4 ----
 unotools/source/misc/syslocale.cxx |   30 ++++++++++++++++--------------
 2 files changed, 16 insertions(+), 18 deletions(-)

New commits:
commit c8e144638c10f81a25478dd8d8061d7d870b383c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 11 13:04:14 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 11 21:13:48 2022 +0200

    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.gran...@collabora.co.uk>

diff --git a/include/unotools/syslocale.hxx b/include/unotools/syslocale.hxx
index ae3153b7976a..e5bc9dd85224 100644
--- a/include/unotools/syslocale.hxx
+++ b/include/unotools/syslocale.hxx
@@ -31,8 +31,6 @@ class LocaleDataWrapper;
 class SvtSysLocale_Impl;
 class SvtSysLocaleOptions;
 
-namespace osl { class Mutex; }
-
 /**
     SvtSysLocale provides a refcounted single instance of an application wide
     LocaleDataWrapper and <type>CharClass</type> which always
@@ -48,8 +46,6 @@ class UNOTOOLS_DLLPUBLIC SvtSysLocale
 
     std::shared_ptr<SvtSysLocale_Impl>  pImpl;
 
-    UNOTOOLS_DLLPRIVATE static  ::osl::Mutex&               GetMutex();
-
 public:
                                         SvtSysLocale();
                                         ~SvtSysLocale();
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);

Reply via email to