summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2018-10-12 11:47:02 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-11-17 17:54:57 +0100
commit170474a638301baceac7e1adb2ab250e5cd4c22a (patch)
treecffb335b80d7e8b78c2734c7ad5cfc80445e6595 /sc
parentf0388c306edfce91241d59420e96a5b2b1c939f5 (diff)
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@collabora.com> (cherry picked from commit 9553f2afd0527ba435dae7bf4506c620a943b150) Reviewed-on: https://gerrit.libreoffice.org/63376 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/global.hxx2
-rw-r--r--sc/source/core/data/global.cxx11
2 files changed, 5 insertions, 8 deletions
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,