From e8d1824146027c708c6dd53cc8341c2677813cde Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Aug 2020 17:02:48 +0200 Subject: use unique_ptr for CalendarWrapper in ScGlobal Change-Id: Id1a00798f9780006de28d3370e5bad1235fa2466 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100537 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/inc/global.hxx | 2 +- sc/source/core/data/global.cxx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index de0b3311c4fc..6d13efab4523 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -522,7 +522,7 @@ class ScGlobal static SvNumberFormatter* pEnglishFormatter; // for UNO / XML export static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix; - static CalendarWrapper* pCalendar; + static std::unique_ptr xCalendar; static std::atomic pCaseCollator; static std::atomic pCollator; static std::atomic<::utl::TransliterationWrapper*> pTransliteration; diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 538702c87097..8b149300bbe3 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -80,7 +80,7 @@ ScUserList* ScGlobal::pUserList = nullptr; LanguageType ScGlobal::eLnge = LANGUAGE_SYSTEM; std::atomic ScGlobal::pLocale(nullptr); std::unique_ptr ScGlobal::xSysLocale; -CalendarWrapper* ScGlobal::pCalendar = nullptr; +std::unique_ptr ScGlobal::xCalendar; std::atomic ScGlobal::pCollator(nullptr); std::atomic ScGlobal::pCaseCollator(nullptr); std::atomic<::utl::TransliterationWrapper*> ScGlobal::pTransliteration(nullptr); @@ -548,7 +548,7 @@ void ScGlobal::Clear() delete pTransliteration.load(); pTransliteration = nullptr; delete pCaseCollator.load(); pCaseCollator = nullptr; delete pCollator.load(); pCollator = nullptr; - DELETEZ(pCalendar); + xCalendar.reset(); xSysLocale.reset(); delete pLocale.load(); pLocale = nullptr; @@ -1025,12 +1025,12 @@ const CharClass* ScGlobal::getCharClassPtr() CalendarWrapper* ScGlobal::GetCalendar() { assert(!bThreadedGroupCalcInProgress); - if ( !pCalendar ) + if ( !xCalendar ) { - pCalendar = new CalendarWrapper( ::comphelper::getProcessComponentContext() ); - pCalendar->loadDefaultCalendar( *GetLocale() ); + xCalendar.reset( new CalendarWrapper( ::comphelper::getProcessComponentContext() ) ); + xCalendar->loadDefaultCalendar( *GetLocale() ); } - return pCalendar; + return xCalendar.get(); } CollatorWrapper* ScGlobal::GetCollator() { -- cgit