diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 10:27:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-04 14:57:27 +0200 |
commit | 8c8543ed7f554eb9b26456dbeba6614e26699c89 (patch) | |
tree | a5e8d575f92c2949238b839942b6a9df737249b9 /sc | |
parent | 30ededbd00c3b69bc7bfe72d1431e17df82542a6 (diff) |
fix more leaks in CppunitTest_sc_cache_test
To be honest, I don't know why this fixes the leak, but it's generally
good practice anyway to use unique_ptr.
Change-Id: Ic5aa2a0c6ab092450e9eae96616a998c08e2e723
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100045
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/global.hxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/dpcache.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 46 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/cellkeytranslator.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/compare.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 2 |
7 files changed, 33 insertions, 35 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 3f7ce5d622ee..309455adc348 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -510,10 +510,10 @@ class ScGlobal static std::map<const char*, OUString>* pRscString; static OUString* pStrScDoc; static SC_DLLPUBLIC const OUString aEmptyOUString; - static OUString* pStrClipDocName; - static SvxBrushItem* pEmptyBrushItem; - static SvxBrushItem* pButtonBrushItem; - static SvxBrushItem* pEmbeddedBrushItem; + static OUString aStrClipDocName; + static std::unique_ptr<SvxBrushItem> xEmptyBrushItem; + static std::unique_ptr<SvxBrushItem> xButtonBrushItem; + static std::unique_ptr<SvxBrushItem> xEmbeddedBrushItem; static ScFunctionList* pStarCalcFunctionList; static ScFunctionMgr* pStarCalcFunctionMgr; @@ -536,7 +536,7 @@ class ScGlobal static void InitPPT(); public: - static SvtSysLocale* pSysLocale; + static std::unique_ptr<SvtSysLocale> xSysLocale; SC_DLLPUBLIC static const LocaleDataWrapper* getLocaleDataPtr(); SC_DLLPUBLIC static const CharClass* getCharClassPtr(); @@ -594,7 +594,7 @@ public: SC_DLLPUBLIC static void Clear(); // at the end of the program static void InitTextHeight(const SfxItemPool* pPool); - static SvxBrushItem* GetEmptyBrushItem() { return pEmptyBrushItem; } + static SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); } static SvxBrushItem* GetButtonBrushItem(); static const OUString& GetEmptyOUString() { return aEmptyOUString; } diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index 32a8a83b2b73..42fafd7fff1d 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -815,7 +815,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const { OUString aQueryStr = rEntry.GetQueryItem().maString.getString(); css::uno::Sequence< sal_Int32 > xOff; - const LanguageType nLang = ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); + const LanguageType nLang = ScGlobal::xSysLocale->GetLanguageTag().getLanguageType(); OUString aCell = pTransliteration->transliterate( aCellStr, nLang, 0, aCellStr.getLength(), &xOff); OUString aQuer = pTransliteration->transliterate( diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index f416d28673fe..538702c87097 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -79,7 +79,7 @@ std::atomic<ScUnoAddInCollection*> ScGlobal::pAddInCollection(nullptr); ScUserList* ScGlobal::pUserList = nullptr; LanguageType ScGlobal::eLnge = LANGUAGE_SYSTEM; std::atomic<css::lang::Locale*> ScGlobal::pLocale(nullptr); -SvtSysLocale* ScGlobal::pSysLocale = nullptr; +std::unique_ptr<SvtSysLocale> ScGlobal::xSysLocale; CalendarWrapper* ScGlobal::pCalendar = nullptr; std::atomic<CollatorWrapper*> ScGlobal::pCollator(nullptr); std::atomic<CollatorWrapper*> ScGlobal::pCaseCollator(nullptr); @@ -87,11 +87,11 @@ std::atomic<::utl::TransliterationWrapper*> ScGlobal::pTransliteration(nullptr); std::atomic<::utl::TransliterationWrapper*> ScGlobal::pCaseTransliteration(nullptr); css::uno::Reference< css::i18n::XOrdinalSuffix> ScGlobal::xOrdinalSuffix; const OUString ScGlobal::aEmptyOUString; -OUString* ScGlobal::pStrClipDocName = nullptr; +OUString ScGlobal::aStrClipDocName; -SvxBrushItem* ScGlobal::pEmptyBrushItem = nullptr; -SvxBrushItem* ScGlobal::pButtonBrushItem = nullptr; -SvxBrushItem* ScGlobal::pEmbeddedBrushItem = nullptr; +std::unique_ptr<SvxBrushItem> ScGlobal::xEmptyBrushItem; +std::unique_ptr<SvxBrushItem> ScGlobal::xButtonBrushItem; +std::unique_ptr<SvxBrushItem> ScGlobal::xEmbeddedBrushItem; ScFunctionList* ScGlobal::pStarCalcFunctionList = nullptr; ScFunctionMgr* ScGlobal::pStarCalcFunctionMgr = nullptr; @@ -430,8 +430,8 @@ OUString ScGlobal::GetLongErrorString(FormulaError nErr) SvxBrushItem* ScGlobal::GetButtonBrushItem() { assert(!bThreadedGroupCalcInProgress); - pButtonBrushItem->SetColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); - return pButtonBrushItem; + xButtonBrushItem->SetColor( Application::GetSettings().GetStyleSettings().GetFaceColor() ); + return xButtonBrushItem.get(); } void ScGlobal::Init() @@ -441,11 +441,11 @@ void ScGlobal::Init() // FIXME: So remove this variable? eLnge = LANGUAGE_SYSTEM; - pSysLocale = new SvtSysLocale; + xSysLocale = std::make_unique<SvtSysLocale>(); - pEmptyBrushItem = new SvxBrushItem( COL_TRANSPARENT, ATTR_BACKGROUND ); - pButtonBrushItem = new SvxBrushItem( Color(), ATTR_BACKGROUND ); - pEmbeddedBrushItem = new SvxBrushItem( COL_LIGHTCYAN, ATTR_BACKGROUND ); + xEmptyBrushItem = std::make_unique<SvxBrushItem>( COL_TRANSPARENT, ATTR_BACKGROUND ); + xButtonBrushItem = std::make_unique<SvxBrushItem>( Color(), ATTR_BACKGROUND ); + xEmbeddedBrushItem = std::make_unique<SvxBrushItem>( COL_LIGHTCYAN, ATTR_BACKGROUND ); InitPPT(); //ScCompiler::InitSymbolsNative(); @@ -456,8 +456,7 @@ void ScGlobal::Init() InitAddIns(); - pStrClipDocName = new OUString( ScResId( SCSTR_NONAME ) ); - *pStrClipDocName += "1"; + aStrClipDocName = ScResId( SCSTR_NONAME ) + "1"; // ScDocumentPool::InitVersionMaps() has been called earlier already } @@ -485,13 +484,13 @@ void ScGlobal::InitPPT() const OUString& ScGlobal::GetClipDocName() { - return *pStrClipDocName; + return aStrClipDocName; } void ScGlobal::SetClipDocName( const OUString& rNew ) { assert(!bThreadedGroupCalcInProgress); - *pStrClipDocName = rNew; + aStrClipDocName = rNew; } void ScGlobal::InitTextHeight(const SfxItemPool* pPool) @@ -541,18 +540,17 @@ void ScGlobal::Clear() ScCompiler::DeInit(); ScInterpreter::GlobalExit(); // Delete static Stack - DELETEZ(pEmptyBrushItem); - DELETEZ(pButtonBrushItem); - DELETEZ(pEmbeddedBrushItem); + xEmptyBrushItem.reset(); + xButtonBrushItem.reset(); + xEmbeddedBrushItem.reset(); DELETEZ(pEnglishFormatter); delete pCaseTransliteration.load(); pCaseTransliteration = nullptr; delete pTransliteration.load(); pTransliteration = nullptr; delete pCaseCollator.load(); pCaseCollator = nullptr; delete pCollator.load(); pCollator = nullptr; DELETEZ(pCalendar); - DELETEZ(pSysLocale); + xSysLocale.reset(); delete pLocale.load(); pLocale = nullptr; - DELETEZ(pStrClipDocName); delete pUnitConverter.load(); pUnitConverter = nullptr; DELETEZ(pFieldEditEngine); @@ -1009,19 +1007,19 @@ utl::TransliterationWrapper* ScGlobal::GetpTransliteration() const LocaleDataWrapper* ScGlobal::getLocaleDataPtr() { OSL_ENSURE( - pSysLocale, + xSysLocale, "ScGlobal::getLocaleDataPtr() called before ScGlobal::Init()"); - return pSysLocale->GetLocaleDataPtr(); + return xSysLocale->GetLocaleDataPtr(); } const CharClass* ScGlobal::getCharClassPtr() { OSL_ENSURE( - pSysLocale, + xSysLocale, "ScGlobal::getCharClassPtr() called before ScGlobal::Init()"); - return pSysLocale->GetCharClassPtr(); + return xSysLocale->GetCharClassPtr(); } CalendarWrapper* ScGlobal::GetCalendar() diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 8ce9cc9552a0..2ce838df8477 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2612,7 +2612,7 @@ public: { const OUString & rValue = pValueSource1 ? pValueSource1->getString() : *pValueSource2; const OUString aQueryStr = rItem.maString.getString(); - const LanguageType nLang = ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); + const LanguageType nLang = ScGlobal::xSysLocale->GetLanguageTag().getLanguageType(); setupTransliteratorIfNeeded(); const OUString aCell( mpTransliteration->transliterate( rValue, nLang, 0, rValue.getLength(), diff --git a/sc/source/core/tool/cellkeytranslator.cxx b/sc/source/core/tool/cellkeytranslator.cxx index 71d84899f79c..381a48a7e5c2 100644 --- a/sc/source/core/tool/cellkeytranslator.cxx +++ b/sc/source/core/tool/cellkeytranslator.cxx @@ -166,7 +166,7 @@ void ScCellKeywordTranslator::transKeyword(OUString& rName, const lang::Locale* spInstance.reset( new ScCellKeywordTranslator ); LanguageType nLang = pLocale ? - LanguageTag(*pLocale).makeFallback().getLanguageType() : ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); + LanguageTag(*pLocale).makeFallback().getLanguageType() : ScGlobal::xSysLocale->GetLanguageTag().getLanguageType(); Sequence<sal_Int32> aOffsets; rName = spInstance->maTransWrapper.transliterate(rName, nLang, 0, rName.getLength(), &aOffsets); lclMatchKeyword(rName, spInstance->maStringNameMap, eOpCode, pLocale); diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx index 6d7150003417..493c33c92d33 100644 --- a/sc/source/core/tool/compare.cxx +++ b/sc/source/core/tool/compare.cxx @@ -164,7 +164,7 @@ double CompareFunc( const Compare& rComp, CompareOptions* pOptions ) } else { - const LanguageType nLang = ScGlobal::pSysLocale->GetLanguageTag().getLanguageType(); + const LanguageType nLang = ScGlobal::xSysLocale->GetLanguageTag().getLanguageType(); OUString aCell( pTransliteration->transliterate( rCell1.maStr.getString(), nLang, 0, rCell1.maStr.getLength(), nullptr)); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index a867220207f4..299f79e1a9b9 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -292,7 +292,7 @@ ScInputWindow::~ScInputWindow() void ScInputWindow::dispose() { - bool bDown = ( ScGlobal::pSysLocale == nullptr ); // after Clear? + bool bDown = !ScGlobal::xSysLocale; // after Clear? // if any view's input handler has a pointer to this input window, reset it // (may be several ones, #74522#) |