From fd84276cf31182c80fc07c88537f9524c4d80e8c Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 25 Sep 2018 15:25:50 +0200 Subject: loplugin:useuniqueptr in VbaApplicationBase_Impl Change-Id: I4ce3cba4a6f5cfec677550a4263bb3e4cc795c49 Reviewed-on: https://gerrit.libreoffice.org/60974 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'vbahelper/source') diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index c10ce37aef61..a441653551e4 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -145,7 +145,7 @@ struct VbaTimerInfoHash } }; -typedef std::unordered_map< VbaTimerInfo, VbaTimer*, VbaTimerInfoHash > VbaTimerHashMap; +typedef std::unordered_map< VbaTimerInfo, std::unique_ptr, VbaTimerInfoHash > VbaTimerHashMap; struct VbaApplicationBase_Impl final { @@ -154,18 +154,6 @@ struct VbaApplicationBase_Impl final OUString msCaption; VbaApplicationBase_Impl() : mbVisible( true ) {} - - ~VbaApplicationBase_Impl() - { - // remove the remaining timers - for ( VbaTimerHashMap::iterator aIter = m_aTimerHash.begin(); - aIter != m_aTimerHash.end(); - ++aIter ) - { - delete aIter->second; - aIter->second = nullptr; - } - } }; VbaApplicationBase::VbaApplicationBase( const uno::Reference< uno::XComponentContext >& xContext ) @@ -395,15 +383,13 @@ void SAL_CALL VbaApplicationBase::OnTime( const uno::Any& aEarliestTime, const O VbaTimerHashMap::iterator aIter = m_pImpl->m_aTimerHash.find( aTimerIndex ); if ( aIter != m_pImpl->m_aTimerHash.end() ) { - delete aIter->second; - aIter->second = nullptr; m_pImpl->m_aTimerHash.erase( aIter ); } if ( bSetTimer ) { VbaTimer* pTimer = new VbaTimer; - m_pImpl->m_aTimerHash[ aTimerIndex ] = pTimer; + m_pImpl->m_aTimerHash[ aTimerIndex ].reset(pTimer); pTimer->Start( this, aFunction, nEarliestTime, nLatestTime ); } } -- cgit