[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 13 12:15:52 UTC 2018
sc/inc/global.hxx | 2 +-
sc/source/core/data/global.cxx | 11 ++++-------
2 files changed, 5 insertions(+), 8 deletions(-)
New commits:
commit 9553f2afd0527ba435dae7bf4506c620a943b150
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Oct 12 11:47:02 2018 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Nov 13 13:15:23 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>
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index c051f54a4148..7c02660300e5 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -516,7 +516,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 a40820c014e1..2138f3e776b8 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -94,7 +94,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;
@@ -565,7 +565,7 @@ void ScGlobal::Clear()
delete pLocale.load(); pLocale = nullptr;
DELETEZ(pStrClipDocName);
- DELETEZ(pUnitConverter);
+ delete pUnitConverter.load(); pUnitConverter = nullptr;
DELETEZ(pFieldEditEngine);
DELETEZ(pEmptyOUString);
@@ -655,11 +655,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