From 6b7d8f4f5f7b4595b29f1ae00c2de4393265d307 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Aug 2020 17:04:44 +0200 Subject: use unique_ptr for ScUserList in ScGlobal Change-Id: Ic7ecb6f67e2dc7ba77c73d0d0eccb758dfed8e33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100538 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/inc/global.hxx | 2 +- sc/source/core/data/global.cxx | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'sc') diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 44b35c003fc1..31c26e8f2db9 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -506,7 +506,7 @@ class ScGlobal static ScAutoFormat* pAutoFormat; static std::atomic pLegacyFuncCollection; static std::atomic pAddInCollection; - static ScUserList* pUserList; + static std::unique_ptr xUserList; static std::map* pRscString; static SC_DLLPUBLIC const OUString aEmptyOUString; static OUString aStrClipDocName; diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 0fc9977ce7f7..02697c0eb84b 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -76,7 +76,7 @@ SvxSearchItem* ScGlobal::pSearchItem = nullptr; ScAutoFormat* ScGlobal::pAutoFormat = nullptr; std::atomic ScGlobal::pLegacyFuncCollection(nullptr); std::atomic ScGlobal::pAddInCollection(nullptr); -ScUserList* ScGlobal::pUserList = nullptr; +std::unique_ptr ScGlobal::xUserList; LanguageType ScGlobal::eLnge = LANGUAGE_SYSTEM; std::atomic ScGlobal::pLocale(nullptr); std::unique_ptr ScGlobal::xSysLocale; @@ -280,9 +280,9 @@ ScUserList* ScGlobal::GetUserList() // Hack: Load Cfg item at the App global_InitAppOptions(); - if (!pUserList) - pUserList = new ScUserList(); - return pUserList; + if (!xUserList) + xUserList.reset(new ScUserList()); + return xUserList.get(); } void ScGlobal::SetUserList( const ScUserList* pNewList ) @@ -290,15 +290,14 @@ void ScGlobal::SetUserList( const ScUserList* pNewList ) assert(!bThreadedGroupCalcInProgress); if ( pNewList ) { - if ( !pUserList ) - pUserList = new ScUserList( *pNewList ); + if ( !xUserList ) + xUserList.reset( new ScUserList( *pNewList ) ); else - *pUserList = *pNewList; + *xUserList = *pNewList; } else { - delete pUserList; - pUserList = nullptr; + xUserList.reset(); } } @@ -533,7 +532,7 @@ void ScGlobal::Clear() DELETEZ(pSearchItem); delete pLegacyFuncCollection.load(); pLegacyFuncCollection = nullptr; delete pAddInCollection.load(); pAddInCollection = nullptr; - DELETEZ(pUserList); + xUserList.reset(); xStarCalcFunctionList.reset(); // Destroy before ResMgr! xStarCalcFunctionMgr.reset(); ScParameterClassification::Exit(); -- cgit