[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Nov 17 16:55:18 UTC 2018


 sc/inc/global.hxx              |    2 +-
 sc/source/core/data/global.cxx |   11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 170474a638301baceac7e1adb2ab250e5cd4c22a
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Oct 12 11:47:02 2018 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Nov 17 17:54:57 2018 +0100

    thread-safe ScGlobal::GetUnitConverter()
    
    Triggered by sc/qa/unit/data/functions/mathematical/fods/convert_ooo.fods
    with SC_FORCE_CALCULATION=threads.
    
    Change-Id: Ibedb32ee03519911650a0deee67011efeda57c93
    Reviewed-on: https://gerrit.libreoffice.org/63175
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
    (cherry picked from commit 9553f2afd0527ba435dae7bf4506c620a943b150)
    Reviewed-on: https://gerrit.libreoffice.org/63376
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index b9ef661f43db..b888b52a116e 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -519,7 +519,7 @@ class ScGlobal
     static ScFunctionList*  pStarCalcFunctionList;
     static ScFunctionMgr*   pStarCalcFunctionMgr;
 
-    static ScUnitConverter* pUnitConverter;
+    static std::atomic<ScUnitConverter*> pUnitConverter;
 
     static  SvNumberFormatter*  pEnglishFormatter;          // for UNO / XML export
 
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index f3819735f6dc..cb5a13ceed0f 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -109,7 +109,7 @@ SvxBrushItem*   ScGlobal::pEmbeddedBrushItem = nullptr;
 ScFunctionList* ScGlobal::pStarCalcFunctionList = nullptr;
 ScFunctionMgr*  ScGlobal::pStarCalcFunctionMgr  = nullptr;
 
-ScUnitConverter* ScGlobal::pUnitConverter = nullptr;
+std::atomic<ScUnitConverter*> ScGlobal::pUnitConverter(nullptr);
 SvNumberFormatter* ScGlobal::pEnglishFormatter = nullptr;
 ScFieldEditEngine* ScGlobal::pFieldEditEngine = nullptr;
 
@@ -586,7 +586,7 @@ void ScGlobal::Clear()
     delete pLocale.load(); pLocale = nullptr;
     DELETEZ(pStrClipDocName);
 
-    DELETEZ(pUnitConverter);
+    delete pUnitConverter.load(); pUnitConverter = nullptr;
     DELETEZ(pFieldEditEngine);
 
     DELETEZ(pEmptyOUString);
@@ -676,11 +676,8 @@ void ScGlobal::ResetFunctionList()
 
 ScUnitConverter* ScGlobal::GetUnitConverter()
 {
-    assert(!bThreadedGroupCalcInProgress);
-    if ( !pUnitConverter )
-        pUnitConverter = new ScUnitConverter;
-
-    return pUnitConverter;
+    return comphelper::doubleCheckedInit( pUnitConverter,
+        []() { return new ScUnitConverter; });
 }
 
 const sal_Unicode* ScGlobal::UnicodeStrChr( const sal_Unicode* pStr,


More information about the Libreoffice-commits mailing list