summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-30 08:57:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-02 08:25:46 +0200
commitd90d9b422789b152416cc66f700a9af2d0a8285d (patch)
treee70ff3b3a69002b1b1b9aa583adeda008fde741a
parent1cb646dc5fe56c614d2740cdc60d382f3d660b6b (diff)
loplugin:useuniqueptr in SfxEventNamesList
Change-Id: Ie296881069393001842f4424f398b0edefd89ac5 Reviewed-on: https://gerrit.libreoffice.org/53702 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/sfx2/evntconf.hxx10
-rw-r--r--sfx2/source/config/evntconf.cxx13
2 files changed, 10 insertions, 13 deletions
diff --git a/include/sfx2/evntconf.hxx b/include/sfx2/evntconf.hxx
index bf59d805a074..670b3ec6b558 100644
--- a/include/sfx2/evntconf.hxx
+++ b/include/sfx2/evntconf.hxx
@@ -27,6 +27,7 @@
#include <sfx2/event.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/macitem.hxx>
+#include <memory>
#include <vector>
class SfxObjectShell;
@@ -49,21 +50,20 @@ struct SFX2_DLLPUBLIC SfxEventName
class SFX2_DLLPUBLIC SfxEventNamesList
{
private:
- ::std::vector< SfxEventName* > aEventNamesList;
- void DelDtor();
+ ::std::vector< std::unique_ptr<SfxEventName> > aEventNamesList;
public:
SfxEventNamesList() {}
SfxEventNamesList( const SfxEventNamesList &rCpy ) { *this = rCpy; }
- ~SfxEventNamesList() { DelDtor(); }
+ ~SfxEventNamesList();
SfxEventNamesList& operator=( const SfxEventNamesList &rCpy );
size_t size() const { return aEventNamesList.size(); };
SfxEventName* at( size_t Index ) const
- { return Index < aEventNamesList.size() ? aEventNamesList[ Index ] : nullptr; }
+ { return Index < aEventNamesList.size() ? aEventNamesList[ Index ].get() : nullptr; }
- void push_back( SfxEventName* Item ) { aEventNamesList.push_back( Item ); }
+ void push_back( std::unique_ptr<SfxEventName> Item ) { aEventNamesList.push_back( std::move(Item) ); }
};
class SFX2_DLLPUBLIC SfxEventNamesItem : public SfxPoolItem
diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx
index 6bf38484b62d..e612c6156fef 100644
--- a/sfx2/source/config/evntconf.cxx
+++ b/sfx2/source/config/evntconf.cxx
@@ -50,21 +50,18 @@ using namespace com::sun::star;
SfxEventNamesList& SfxEventNamesList::operator=( const SfxEventNamesList& rTbl )
{
- DelDtor();
+ aEventNamesList.clear();
for ( size_t i = 0, n = rTbl.size(); i < n; ++i )
{
SfxEventName* pTmp = rTbl.at( i );
- SfxEventName* pNew = new SfxEventName( *pTmp );
- aEventNamesList.push_back( pNew );
+ std::unique_ptr<SfxEventName> pNew(new SfxEventName( *pTmp ));
+ aEventNamesList.push_back( std::move(pNew) );
}
return *this;
}
-void SfxEventNamesList::DelDtor()
+SfxEventNamesList::~SfxEventNamesList()
{
- for (SfxEventName* i : aEventNamesList)
- delete i;
- aEventNamesList.clear();
}
bool SfxEventNamesItem::operator==( const SfxPoolItem& rAttr ) const
@@ -114,7 +111,7 @@ sal_uInt16 SfxEventNamesItem::GetVersion( sal_uInt16 ) const
void SfxEventNamesItem::AddEvent( const OUString& rName, const OUString& rUIName, SvMacroItemId nID )
{
- aEventsList.push_back( new SfxEventName( nID, rName, !rUIName.isEmpty() ? rUIName : rName ) );
+ aEventsList.push_back( std::unique_ptr<SfxEventName>(new SfxEventName( nID, rName, !rUIName.isEmpty() ? rUIName : rName )) );
}