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

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 23 06:45:21 UTC 2018


 sfx2/source/appl/helpinterceptor.cxx |   20 +++++---------------
 sfx2/source/appl/helpinterceptor.hxx |    5 ++---
 2 files changed, 7 insertions(+), 18 deletions(-)

New commits:
commit 1f75cda1d842717248c6dc926a9d2cd06f39d85b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 16 15:28:46 2018 +0200

    loplugin:useuniqueptr in HelpInterceptor_Impl
    
    Change-Id: I75c1ca2d6b0e03604bb6c96d2613261a1a05b988
    Reviewed-on: https://gerrit.libreoffice.org/48297
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/appl/helpinterceptor.cxx b/sfx2/source/appl/helpinterceptor.cxx
index 03f81a25e358..a41fc472a02b 100644
--- a/sfx2/source/appl/helpinterceptor.cxx
+++ b/sfx2/source/appl/helpinterceptor.cxx
@@ -47,29 +47,20 @@ HelpInterceptor_Impl::HelpInterceptor_Impl() :
 
 HelpInterceptor_Impl::~HelpInterceptor_Impl()
 {
-    if ( m_pHistory )
-    {
-        for (HelpHistoryEntry_Impl* p : *m_pHistory)
-            delete p;
-        delete m_pHistory;
-    }
 }
 
 
 void HelpInterceptor_Impl::addURL( const OUString& rURL )
 {
   if ( !m_pHistory )
-        m_pHistory = new HelpHistoryList_Impl;
+        m_pHistory.reset( new std::vector<std::unique_ptr<HelpHistoryEntry_Impl>> );
 
     size_t nCount = m_pHistory->size();
     if ( nCount && m_nCurPos < ( nCount - 1 ) )
     {
         for ( size_t i = nCount - 1; i > m_nCurPos; i-- )
         {
-            delete m_pHistory->at( i );
-            HelpHistoryList_Impl::iterator it = m_pHistory->begin();
-            ::std::advance( it, i );
-            m_pHistory->erase( it );
+            m_pHistory->erase( m_pHistory->begin() + i );
         }
     }
     Reference<XFrame> xFrame(m_xIntercepted, UNO_QUERY);
@@ -83,7 +74,7 @@ void HelpInterceptor_Impl::addURL( const OUString& rURL )
 
     m_aCurrentURL = rURL;
     Any aEmptyViewData;
-    m_pHistory->push_back( new HelpHistoryEntry_Impl( rURL, aEmptyViewData ) );
+    m_pHistory->emplace_back( new HelpHistoryEntry_Impl( rURL, aEmptyViewData ) );
     m_nCurPos = m_pHistory->size() - 1;
 // TODO ?
     if ( m_xListener.is() )
@@ -229,9 +220,8 @@ void SAL_CALL HelpInterceptor_Impl::dispatch(
 
             if ( nPos < ULONG_MAX )
             {
-                HelpHistoryEntry_Impl* pEntry = m_pHistory->at( nPos );
-                if ( pEntry )
-                    m_pWindow->loadHelpContent(pEntry->aURL, false); // false => don't add item to history again!
+                HelpHistoryEntry_Impl* pEntry = m_pHistory->at( nPos ).get();
+                m_pWindow->loadHelpContent(pEntry->aURL, false); // false => don't add item to history again!
             }
 
             m_pWindow->UpdateToolbox();
diff --git a/sfx2/source/appl/helpinterceptor.hxx b/sfx2/source/appl/helpinterceptor.hxx
index 41d9665f264b..92897d892343 100644
--- a/sfx2/source/appl/helpinterceptor.hxx
+++ b/sfx2/source/appl/helpinterceptor.hxx
@@ -29,6 +29,7 @@
 #include <tools/link.hxx>
 #include <vcl/vclptr.hxx>
 #include <vector>
+#include <memory>
 
 struct HelpHistoryEntry_Impl
 {
@@ -39,8 +40,6 @@ struct HelpHistoryEntry_Impl
         aURL( rURL ), aViewData(rViewData) {}
 };
 
-typedef ::std::vector< HelpHistoryEntry_Impl* > HelpHistoryList_Impl;
-
 class SfxHelpWindow_Impl;
 class HelpInterceptor_Impl : public ::cppu::WeakImplHelper<
         css::frame::XDispatchProviderInterceptor,
@@ -61,7 +60,7 @@ friend class SfxHelpWindow_Impl;
 
     css::uno::Reference< css::frame::XStatusListener > m_xListener;
 
-    HelpHistoryList_Impl*       m_pHistory;
+    std::unique_ptr<std::vector<std::unique_ptr<HelpHistoryEntry_Impl>>> m_pHistory;
     VclPtr<SfxHelpWindow_Impl>  m_pWindow;
     sal_uIntPtr                 m_nCurPos;
     OUString                    m_aCurrentURL;


More information about the Libreoffice-commits mailing list