diff options
author | Arnaud VERSINI <arnaud.versini@libreoffice.org> | 2022-12-31 19:22:03 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-01-05 22:13:35 +0000 |
commit | 3ab8349a37215d8e355e79b93d66f631144e7c57 (patch) | |
tree | 2b1689736f4ecf075527bbfb8de889ea232caac4 /sc | |
parent | 9817a03e03988b86050c0fe0e4cd4cca476f172f (diff) |
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 <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/compiler.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 12 |
2 files changed, 9 insertions, 4 deletions
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(), |