diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2018-06-22 13:28:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-30 13:36:42 +0200 |
commit | d90a25d2fe3c6fe46aa3e21ff5cd48aab4251840 (patch) | |
tree | 8bb915105a0a02b8af2165ee0289f76e7e859b20 /sc/source | |
parent | fc32fd280efe27f7618b4905ffc232a824cf9666 (diff) |
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@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 8617c8ed9047e46808c292bd68e5b573aa7af74d)
Reviewed-on: https://gerrit.libreoffice.org/56451
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 34 |
1 files changed, 16 insertions, 18 deletions
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() ) ); } |