summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2018-05-25 13:03:28 +0200
committerLuboš Luňák <l.lunak@collabora.com>2018-06-04 16:13:41 +0200
commit512d3cc11289fe3344212e73dc39bfdda846f02b (patch)
tree9d54029a1c47230cdf0c97261242c90af8752930 /sc
parent64040ca17910ac2904e33305d41736dd9942eb9c (diff)
add mutex protection to more ScGlobal functions
Similarly to ScGlobal::Get(Case)Collator(), these also may be called by multiple threads. Change-Id: If0b1f2669282354ce79cdd251698f3aa1c6a30d4 Reviewed-on: https://gerrit.libreoffice.org/54798 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/55281 Tested-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/global.cxx53
1 files changed, 22 insertions, 31 deletions
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index bf76a7085758..2c3a98622d63 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -305,18 +305,12 @@ ScAutoFormat* ScGlobal::GetOrCreateAutoFormat()
LegacyFuncCollection* ScGlobal::GetLegacyFuncCollection()
{
- assert(!bThreadedGroupCalcInProgress);
- if (!pLegacyFuncCollection)
- pLegacyFuncCollection = new LegacyFuncCollection();
- return pLegacyFuncCollection;
+ return doubleCheckedInit( pLegacyFuncCollection, []() { return new LegacyFuncCollection(); });
}
ScUnoAddInCollection* ScGlobal::GetAddInCollection()
{
- assert(!bThreadedGroupCalcInProgress);
- if (!pAddInCollection)
- pAddInCollection = new ScUnoAddInCollection();
- return pAddInCollection;
+ return doubleCheckedInit( pAddInCollection, []() { return new ScUnoAddInCollection(); });
}
ScUserList* ScGlobal::GetUserList()
@@ -1008,26 +1002,27 @@ void ScGlobal::AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatte
utl::TransliterationWrapper* ScGlobal::GetpTransliteration()
{
- assert(!bThreadedGroupCalcInProgress);
- if ( !pTransliteration )
- {
- const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
- pTransliteration = new ::utl::TransliterationWrapper(
- ::comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE );
- pTransliteration->loadModuleIfNeeded( eOfficeLanguage );
- }
- return pTransliteration;
+ return doubleCheckedInit( pTransliteration,
+ []()
+ {
+ const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
+ ::utl::TransliterationWrapper* p = new ::utl::TransliterationWrapper(
+ ::comphelper::getProcessComponentContext(), TransliterationFlags::IGNORE_CASE );
+ p->loadModuleIfNeeded( eOfficeLanguage );
+ return p;
+ });
}
::utl::TransliterationWrapper* ScGlobal::GetCaseTransliteration()
{
- assert(!bThreadedGroupCalcInProgress);
- if ( !pCaseTransliteration )
- {
- const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
- pCaseTransliteration = new ::utl::TransliterationWrapper(::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
- pCaseTransliteration->loadModuleIfNeeded( eOfficeLanguage );
- }
- return pCaseTransliteration;
+ return doubleCheckedInit( pCaseTransliteration,
+ []()
+ {
+ const LanguageType eOfficeLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
+ ::utl::TransliterationWrapper* p = new ::utl::TransliterationWrapper(
+ ::comphelper::getProcessComponentContext(), TransliterationFlags::NONE );
+ p->loadModuleIfNeeded( eOfficeLanguage );
+ return p;
+ });
}
const LocaleDataWrapper* ScGlobal::GetpLocaleData()
@@ -1069,12 +1064,8 @@ CollatorWrapper* ScGlobal::GetCaseCollator()
}
css::lang::Locale* ScGlobal::GetLocale()
{
- assert(!bThreadedGroupCalcInProgress);
- if ( !pLocale )
- {
- pLocale = new css::lang::Locale( Application::GetSettings().GetLanguageTag().getLocale());
- }
- return pLocale;
+ return doubleCheckedInit( pLocale,
+ []() { return new css::lang::Locale( Application::GetSettings().GetLanguageTag().getLocale()); });
}
ScFieldEditEngine& ScGlobal::GetStaticFieldEditEngine()