summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-12-28 18:10:32 +0100
committerJulien Nabet <serval2412@yahoo.fr>2017-12-28 23:16:33 +0100
commit7794b2d96f5259b062ca6bd9db265a086631593f (patch)
treedbf1007b27b261a62811498b7dc7930fb8ae1dcc /cui
parent7facb7d6362d7fcb3aaf60ab9ab4768213e1d3d6 (diff)
Use unique_ptr for VectorOfNodes (cui/treeopt)
Change-Id: I318128452fc6d76038c0ed41fcb0a5e7999952c4 Reviewed-on: https://gerrit.libreoffice.org/47146 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/treeopt.hxx2
-rw-r--r--cui/source/options/treeopt.cxx31
2 files changed, 14 insertions, 19 deletions
diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx
index 3eadd58ef5d4..126d96e49442 100644
--- a/cui/source/inc/treeopt.hxx
+++ b/cui/source/inc/treeopt.hxx
@@ -95,7 +95,7 @@ struct OptionsNode
m_bAllModules( bAllModules ) {}
};
-typedef std::vector< OptionsNode* > VectorOfNodes;
+typedef std::vector< std::unique_ptr<OptionsNode> > VectorOfNodes;
struct LastPageSaver
{
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 07be7d1a788c..065ebf51a764 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1863,12 +1863,10 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
OUString sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
if ( !sTemp.isEmpty() )
sLabel = sTemp;
- OptionsNode* pNode =
- new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules );
+ std::unique_ptr<OptionsNode> pNode(new OptionsNode(sNodeId, sLabel, sPageURL, bAllModules));
- if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
+ if ( rExtensionId.isEmpty() && !isNodeActive( pNode.get(), pModule ) )
{
- delete pNode;
continue;
}
@@ -1938,10 +1936,8 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
// do not insert nodes without leaves
if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
{
- pModule ? aNodeList.push_back( pNode ) : aOutNodeList.push_back( pNode );
+ pModule ? aNodeList.push_back( std::move(pNode) ) : aOutNodeList.push_back( std::move(pNode) );
}
- else
- delete pNode;
}
}
@@ -1952,18 +1948,17 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
OUString sNodeId = i->m_sId;
for ( auto j = aNodeList.begin(); j != aNodeList.end(); ++j )
{
- OptionsNode* pNode = *j;
- if ( pNode->m_sId == sNodeId )
+ if ( (*j)->m_sId == sNodeId )
{
- aOutNodeList.push_back( pNode );
+ aOutNodeList.push_back( std::move(*j) );
aNodeList.erase( j );
break;
}
}
}
- for ( auto const & i: aNodeList )
- aOutNodeList.push_back( i );
+ for ( auto & i: aNodeList )
+ aOutNodeList.push_back( std::move(i) );
}
return aOutNodeList;
}
@@ -2014,21 +2009,21 @@ static void lcl_insertLeaf(
void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
{
- for (OptionsNode* pNode : rNodeList)
+ for (auto const& node : rNodeList)
{
- if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
+ if ( node->m_aLeaves.size() > 0 || node->m_aGroupedLeaves.size() > 0 )
{
- for ( auto const & j: pNode->m_aGroupedLeaves )
+ for ( auto const & j: node->m_aGroupedLeaves )
{
for ( size_t k = 0; k < j.size(); ++k )
{
- lcl_insertLeaf( this, pNode, j[k].get(), *pTreeLB );
+ lcl_insertLeaf( this, node.get(), j[k].get(), *pTreeLB );
}
}
- for ( auto const & j: pNode->m_aLeaves )
+ for ( auto const & j: node->m_aLeaves )
{
- lcl_insertLeaf( this, pNode, j.get(), *pTreeLB );
+ lcl_insertLeaf( this, node.get(), j.get(), *pTreeLB );
}
}
}