sc/source/core/tool/interpr1.cxx | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
New commits: commit 8617c8ed9047e46808c292bd68e5b573aa7af74d Author: Luboš Luňák <l.lu...@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.gran...@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> 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() ) ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits