[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/source
Luboš Luňák
l.lunak at collabora.com
Sat Jun 30 11:37:03 UTC 2018
sc/source/core/tool/interpr1.cxx | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
New commits:
commit d90a25d2fe3c6fe46aa3e21ff5cd48aab4251840
Author: Luboš Luňák <l.lunak at collabora.com>
Date: Fri Jun 22 13:28:25 2018 +0200
thread-safe initialization of transliteration objects
Otherwise causes problem with ooo#70213-3 (and
mnOpenCLMinimumFormulaGroupSize disabled).
Change-Id: I3acfad34476e74595b55a559df5bfd72945a1869
Reviewed-on: https://gerrit.libreoffice.org/56291
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
(cherry picked from commit 8617c8ed9047e46808c292bd68e5b573aa7af74d)
Reviewed-on: https://gerrit.libreoffice.org/56451
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 9adedd0729ea..d4bd096e7fe9 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3388,29 +3388,27 @@ void ScInterpreter::ScChar()
static OUString lcl_convertIntoHalfWidth( const OUString & rStr )
{
- static bool bFirstASCCall = true;
- static utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
-
- if( bFirstASCCall )
- {
- aTrans.loadModuleByImplName( "FULLWIDTH_HALFWIDTH_LIKE_ASC", LANGUAGE_SYSTEM );
- bFirstASCCall = false;
- }
-
+ // Make the initialization thread-safe. Since another function needs to be called, move it all to another
+ // function and thread-safely initialize a static reference in this function.
+ auto init = []() -> utl::TransliterationWrapper&
+ {
+ static utl::TransliterationWrapper trans( ::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
+ trans.loadModuleByImplName( "FULLWIDTH_HALFWIDTH_LIKE_ASC", LANGUAGE_SYSTEM );
+ return trans;
+ };
+ static utl::TransliterationWrapper& aTrans( init());
return aTrans.transliterate( rStr, 0, sal_uInt16( rStr.getLength() ) );
}
static OUString lcl_convertIntoFullWidth( const OUString & rStr )
{
- static bool bFirstJISCall = true;
- static utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
-
- if( bFirstJISCall )
- {
- aTrans.loadModuleByImplName( "HALFWIDTH_FULLWIDTH_LIKE_JIS", LANGUAGE_SYSTEM );
- bFirstJISCall = false;
- }
-
+ auto init = []() -> utl::TransliterationWrapper&
+ {
+ static utl::TransliterationWrapper trans( ::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
+ trans.loadModuleByImplName( "HALFWIDTH_FULLWIDTH_LIKE_JIS", LANGUAGE_SYSTEM );
+ return trans;
+ };
+ static utl::TransliterationWrapper& aTrans( init());
return aTrans.transliterate( rStr, 0, sal_uInt16( rStr.getLength() ) );
}
More information about the Libreoffice-commits
mailing list