From 35ba29e093d41ce88a827ab145ba8df09ff0ee2f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 6 Feb 2018 10:49:49 +0200 Subject: loplugin:useuniqueptr in SpellChecker Change-Id: I36a9fe01e228f3f2f5e441c369291da4c461f735 Reviewed-on: https://gerrit.libreoffice.org/49874 Tested-by: Jenkins Reviewed-by: Noel Grandin --- lingucomponent/source/spellcheck/spell/sspellimp.cxx | 9 +++------ lingucomponent/source/spellcheck/spell/sspellimp.hxx | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'lingucomponent') diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index 12b9e240fa24..db6c183a8cef 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -72,7 +72,6 @@ using namespace linguistic; SpellChecker::SpellChecker() : m_aEvtListeners(GetLinguMutex()), - m_pPropHelper(nullptr), m_bDisposing(false) { } @@ -87,7 +86,6 @@ SpellChecker::~SpellChecker() if (m_pPropHelper) { m_pPropHelper->RemoveAsPropListener(); - delete m_pPropHelper; } } @@ -97,7 +95,7 @@ PropertyHelper_Spelling & SpellChecker::GetPropHelper_Impl() { Reference< XLinguProperties > xPropSet( GetLinguProperties(), UNO_QUERY ); - m_pPropHelper = new PropertyHelper_Spelling( static_cast(this), xPropSet ); + m_pPropHelper.reset( new PropertyHelper_Spelling( static_cast(this), xPropSet ) ); m_pPropHelper->AddAsPropListener(); //! after a reference is established } return *m_pPropHelper; @@ -577,7 +575,7 @@ void SAL_CALL SpellChecker::initialize( const Sequence< Any >& rArguments ) //! And the reference to the UNO-functions while increasing //! the ref-count and will implicitly free the memory //! when the object is no longer used. - m_pPropHelper = new PropertyHelper_Spelling( static_cast(this), xPropSet ); + m_pPropHelper.reset( new PropertyHelper_Spelling( static_cast(this), xPropSet ) ); m_pPropHelper->AddAsPropListener(); //! after a reference is established } else { @@ -598,8 +596,7 @@ void SAL_CALL SpellChecker::dispose() if (m_pPropHelper) { m_pPropHelper->RemoveAsPropListener(); - delete m_pPropHelper; - m_pPropHelper = nullptr; + m_pPropHelper.reset(); } } } diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx index d8e5581463da..82ddbedf0af3 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx @@ -69,7 +69,7 @@ class SpellChecker : Sequence< Locale > m_aSuppLocales; ::comphelper::OInterfaceContainerHelper2 m_aEvtListeners; - linguistic::PropertyHelper_Spelling* m_pPropHelper; + std::unique_ptr m_pPropHelper; bool m_bDisposing; SpellChecker(const SpellChecker &) = delete; -- cgit