diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-11 17:08:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-12 08:57:37 +0200 |
commit | e51621d23d333c6d5d0279f5da30fcfd16d5ef9b (patch) | |
tree | 6a4a4753aca13ee28c33b2636965222d651064d0 /sc | |
parent | 6b7d8f4f5f7b4595b29f1ae00c2de4393265d307 (diff) |
use unique_ptr for SvxSearchItem in ScGlobal
Change-Id: I45f5d2bb699ef8cc6f32995bf15c2bf9095704fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100557
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/global.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 19 |
2 files changed, 10 insertions, 11 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 31c26e8f2db9..bc576c9528ff 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -502,7 +502,7 @@ namespace utl { class ScGlobal { - static SvxSearchItem* pSearchItem; + static std::unique_ptr<SvxSearchItem> xSearchItem; static ScAutoFormat* pAutoFormat; static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection; static std::atomic<ScUnoAddInCollection*> pAddInCollection; diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 02697c0eb84b..f8b87ba369ae 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -72,7 +72,7 @@ #include <docsh.hxx> tools::SvRef<ScDocShell> ScGlobal::xDrawClipDocShellRef; -SvxSearchItem* ScGlobal::pSearchItem = nullptr; +std::unique_ptr<SvxSearchItem> ScGlobal::xSearchItem; ScAutoFormat* ScGlobal::pAutoFormat = nullptr; std::atomic<LegacyFuncCollection*> ScGlobal::pLegacyFuncCollection(nullptr); std::atomic<ScUnoAddInCollection*> ScGlobal::pAddInCollection(nullptr); @@ -214,23 +214,22 @@ bool ScGlobal::CheckWidthInvalidate( bool& bNumFormatChanged, const SvxSearchItem& ScGlobal::GetSearchItem() { assert(!bThreadedGroupCalcInProgress); - if (!pSearchItem) + if (!xSearchItem) { - pSearchItem = new SvxSearchItem( SID_SEARCH_ITEM ); - pSearchItem->SetAppFlag( SvxSearchApp::CALC ); + xSearchItem.reset(new SvxSearchItem( SID_SEARCH_ITEM )); + xSearchItem->SetAppFlag( SvxSearchApp::CALC ); } - return *pSearchItem; + return *xSearchItem; } void ScGlobal::SetSearchItem( const SvxSearchItem& rNew ) { assert(!bThreadedGroupCalcInProgress); // FIXME: An assignment operator would be nice here - delete pSearchItem; - pSearchItem = rNew.Clone(); + xSearchItem.reset(rNew.Clone()); - pSearchItem->SetWhich( SID_SEARCH_ITEM ); - pSearchItem->SetAppFlag( SvxSearchApp::CALC ); + xSearchItem->SetWhich( SID_SEARCH_ITEM ); + xSearchItem->SetAppFlag( SvxSearchApp::CALC ); } void ScGlobal::ClearAutoFormat() @@ -529,7 +528,7 @@ void ScGlobal::Clear() theAddInAsyncTbl.clear(); ExitExternalFunc(); ClearAutoFormat(); - DELETEZ(pSearchItem); + xSearchItem.reset(); delete pLegacyFuncCollection.load(); pLegacyFuncCollection = nullptr; delete pAddInCollection.load(); pAddInCollection = nullptr; xUserList.reset(); |