[Libreoffice-commits] core.git: vbahelper/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 26 07:00:02 UTC 2018


 vbahelper/source/vbahelper/vbaapplicationbase.cxx |   18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

New commits:
commit fd84276cf31182c80fc07c88537f9524c4d80e8c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 25 15:25:50 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 26 08:59:39 2018 +0200

    loplugin:useuniqueptr in VbaApplicationBase_Impl
    
    Change-Id: I4ce3cba4a6f5cfec677550a4263bb3e4cc795c49
    Reviewed-on: https://gerrit.libreoffice.org/60974
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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<VbaTimer>, 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 );
     }
 }


More information about the Libreoffice-commits mailing list