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

Julien Nabet serval2412 at yahoo.fr
Thu Jan 11 08:39:13 UTC 2018


 cui/source/inc/treeopt.hxx     |    4 ++--
 cui/source/options/treeopt.cxx |   18 ++++++++----------
 2 files changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 42bfd59b6ba9e7a53ba789f04694060cc43d9d88
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Dec 30 08:26:25 2017 +0100

    Use more unique_ptr in treeopt (cui)
    
    Change-Id: I2041bf8c5d0ddcc0fb62978055381280a64094c4
    Reviewed-on: https://gerrit.libreoffice.org/47187
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx
index 126d96e49442..e71302449678 100644
--- a/cui/source/inc/treeopt.hxx
+++ b/cui/source/inc/treeopt.hxx
@@ -46,7 +46,7 @@ struct OrderedEntry
 struct Module
 {
     bool                          m_bActive;
-    std::vector< OrderedEntry* >  m_aNodeList;
+    std::vector< std::unique_ptr<OrderedEntry> >  m_aNodeList;
 
     Module() : m_bActive( false ) {}
 };
@@ -150,7 +150,7 @@ private:
     void            LoadExtensionOptions( const OUString& rExtensionId );
     static OUString GetModuleIdentifier( const css::uno::Reference<
                                             css::frame::XFrame >& xFrame );
-    static Module*  LoadModule( const OUString& rModuleIdentifier );
+    static std::unique_ptr<Module>  LoadModule( const OUString& rModuleIdentifier );
     static VectorOfNodes LoadNodes( Module* pModule, const OUString& rExtensionId );
     void            InsertNodes( const VectorOfNodes& rNodeList );
 
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 065ebf51a764..2d06f7703210 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1710,7 +1710,7 @@ bool isNodeActive( OptionsNode const * pNode, Module* pModule )
         // search node in active module
         if ( pModule->m_bActive )
         {
-            for (OrderedEntry* j : pModule->m_aNodeList)
+            for (auto const& j : pModule->m_aNodeList)
                 if ( j->m_sId == pNode->m_sId )
                     return true;
         }
@@ -1720,7 +1720,7 @@ bool isNodeActive( OptionsNode const * pNode, Module* pModule )
 
 void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
 {
-    Module* pModule = nullptr;
+    std::unique_ptr<Module> pModule;
 
     // when called by Tools - Options then load nodes of active module
     if ( rExtensionId.isEmpty() )
@@ -1728,10 +1728,8 @@ void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
         pModule = LoadModule( GetModuleIdentifier( Reference< XFrame >() ) );
     }
 
-    VectorOfNodes aNodeList = LoadNodes( pModule, rExtensionId );
+    VectorOfNodes aNodeList = LoadNodes( pModule.get(), rExtensionId );
     InsertNodes( aNodeList );
-
-    delete pModule;
 }
 
 OUString OfaTreeOptionsDialog::GetModuleIdentifier( const Reference< XFrame >& rFrame )
@@ -1765,10 +1763,10 @@ OUString OfaTreeOptionsDialog::GetModuleIdentifier( const Reference< XFrame >& r
     return sModule;
 }
 
-Module* OfaTreeOptionsDialog::LoadModule(
+std::unique_ptr<Module> OfaTreeOptionsDialog::LoadModule(
     const OUString& rModuleIdentifier )
 {
-    Module* pModule = nullptr;
+    std::unique_ptr<Module> pModule;
     Reference< XNameAccess > xSet(
         officecfg::Office::OptionsDialog::Modules::get());
 
@@ -1779,7 +1777,7 @@ Module* OfaTreeOptionsDialog::LoadModule(
         if ( rModuleIdentifier == sModule )
         {
             // current active module found
-            pModule = new Module;
+            pModule.reset(new Module);
             pModule->m_bActive = true;
 
             Reference< XNameAccess > xModAccess;
@@ -1803,7 +1801,7 @@ Module* OfaTreeOptionsDialog::LoadModule(
                             if ( nIndex < 0 )
                                 // append nodes with index < 0
                                 pModule->m_aNodeList.push_back(
-                                    new OrderedEntry( nIndex, xTemp[x] ) );
+                                 std::unique_ptr<OrderedEntry>(new OrderedEntry(nIndex, xTemp[x])));
                             else
                             {
                                 // search position of the node
@@ -1817,7 +1815,7 @@ Module* OfaTreeOptionsDialog::LoadModule(
                                 // and insert the node on this position
                                 pModule->m_aNodeList.insert(
                                     pModule->m_aNodeList.begin() + y,
-                                    new OrderedEntry( nIndex, xTemp[x] ) );
+                                    std::unique_ptr<OrderedEntry>(new OrderedEntry( nIndex, xTemp[x] )) );
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list