[Libreoffice-commits] core.git: sc/source
Luboš Luňák
l.lunak at collabora.com
Sat Jun 2 21:48:41 UTC 2018
sc/source/core/data/global.cxx | 53 +++++++++++++++++------------------------
1 file changed, 22 insertions(+), 31 deletions(-)
New commits:
commit bfed5c384d41253bec39fc3e44f839242602f1a1
Author: Luboš Luňák <l.lunak at collabora.com>
Date: Fri May 25 13:03:28 2018 +0200
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 at libreoffice.org>
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
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()
More information about the Libreoffice-commits
mailing list