sc/inc/compiler.hxx              |    1 -
 sc/source/core/tool/compiler.cxx |   12 +++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 3ab8349a37215d8e355e79b93d66f631144e7c57
Author:     Arnaud VERSINI <arnaud.vers...@libreoffice.org>
AuthorDate: Sat Dec 31 19:22:03 2022 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Jan 5 22:13:35 2023 +0000

    sc : use std::mutex for CharClass initialisation
    
    Change-Id: I0427109da1bfed1d3d467455ab1ab3c68569f60b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144886
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0097486c223c..fbf5073743e1 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -258,7 +258,6 @@ public:
 
 private:
 
-    static osl::Mutex           maMutex;
     static const CharClass      *pCharClassEnglish;     // character 
classification for en_US locale
     static const CharClass      *pCharClassLocalized;   // character 
classification for UI locale
     static const Convention     *pConventions[ 
formula::FormulaGrammar::CONV_LAST ];
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 371ee5aad209..f3861e4ddbbe 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -21,6 +21,7 @@
 
 #include <compiler.hxx>
 
+#include <mutex>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <sfx2/app.hxx>
@@ -77,7 +78,6 @@ using namespace formula;
 using namespace ::com::sun::star;
 using ::std::vector;
 
-osl::Mutex                          ScCompiler::maMutex;
 const CharClass*                    ScCompiler::pCharClassEnglish = nullptr;
 const CharClass*                    ScCompiler::pCharClassLocalized = nullptr;
 const ScCompiler::Convention*       ScCompiler::pConventions[ ]   = { nullptr, 
nullptr, nullptr, nullptr, nullptr, nullptr };
@@ -222,11 +222,17 @@ bool ScCompiler::IsEnglishSymbol( const OUString& rName )
     return !aIntName.isEmpty();       // no valid function name
 }
 
+static std::mutex& getCharClassMutex()
+{
+    static std::mutex aMutex;
+    return aMutex;
+}
+
 const CharClass* ScCompiler::GetCharClassEnglish()
 {
     if (!pCharClassEnglish)
     {
-        osl::MutexGuard aGuard(maMutex);
+        std::scoped_lock aGuard(getCharClassMutex());
         if (!pCharClassEnglish)
         {
             pCharClassEnglish = new CharClass( 
::comphelper::getProcessComponentContext(),
@@ -242,7 +248,7 @@ const CharClass* ScCompiler::GetCharClassLocalized()
     {
         // Switching UI language requires restart; if not, we would have to
         // keep track of that.
-        osl::MutexGuard aGuard(maMutex);
+        std::scoped_lock aGuard(getCharClassMutex());
         if (!pCharClassLocalized)
         {
             pCharClassLocalized = new CharClass( 
::comphelper::getProcessComponentContext(),

Reply via email to