diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-30 10:29:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-05 07:55:44 +0100 |
commit | 9d6e774f51998deadae429061715f92a7af1b0b0 (patch) | |
tree | 36bf773d27d6a66f70b2933784baa63bd11da015 /svx | |
parent | 748167da4e5a7f406d3fec93c9e61a534ec64037 (diff) |
loplugin:useuniqueptr in Gallery
Change-Id: Ia12805bff0403fe260786360233be677ef91f710
Reviewed-on: https://gerrit.libreoffice.org/49208
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 219ced254d44..3d3107296a9b 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -259,10 +259,6 @@ Gallery::Gallery( const OUString& rMultiPath ) Gallery::~Gallery() { - // erase theme list - for (GalleryThemeEntry* p : aThemeList) - delete p; - aThemeList.clear(); } Gallery* Gallery::GetGalleryInstance() @@ -478,7 +474,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly ); if( pEntry ) - aThemeList.push_back( pEntry ); + aThemeList.emplace_back( pEntry ); } } catch( const ucb::ContentCreationException& ) @@ -508,16 +504,14 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO GalleryThemeEntry* Gallery::ImplGetThemeEntry( const OUString& rThemeName ) { - GalleryThemeEntry* pFound = nullptr; - if( !rThemeName.isEmpty() ) { - for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i ) + for ( size_t i = 0, n = aThemeList.size(); i < n; ++i ) if( rThemeName == aThemeList[ i ]->GetThemeName() ) - pFound = aThemeList[ i ]; + return aThemeList[ i ].get(); } - return pFound; + return nullptr; } OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const @@ -526,7 +520,7 @@ OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i ) { - GalleryThemeEntry* pEntry = aThemeList[ i ]; + GalleryThemeEntry* pEntry = aThemeList[ i ].get(); if( nThemeId == pEntry->GetId() ) pFound = pEntry; } @@ -616,7 +610,7 @@ bool Gallery::CreateTheme( const OUString& rThemeName ) true, aURL, rThemeName, false, true, 0, false ); - aThemeList.push_back( pNewEntry ); + aThemeList.emplace_back( pNewEntry ); delete new GalleryTheme( this, pNewEntry ); Broadcast( GalleryHint( GalleryHintType::THEME_CREATED, rThemeName ) ); bRet = true; @@ -673,11 +667,10 @@ bool Gallery::RemoveTheme( const OUString& rThemeName ) KillFile( aStrURL ); } - GalleryThemeList::const_iterator aEnd = aThemeList.end(); - for ( GalleryThemeList::iterator it = aThemeList.begin(); it != aEnd; ++it ) + auto aEnd = aThemeList.end(); + for ( auto it = aThemeList.begin(); it != aEnd; ++it ) { - if ( pThemeEntry == *it ) { - delete pThemeEntry; + if ( pThemeEntry == it->get() ) { aThemeList.erase( it ); break; } |