diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-20 09:54:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-21 08:35:59 +0200 |
commit | 5779775c6dd831205a296393a2cca26a9120d2ea (patch) | |
tree | d00173ba8157ac2f2c7e7b088e7bdb02caca4de9 | |
parent | b1da360e9230f5a1d1d5e03bd8f83f65e7e14edc (diff) |
loplugin:useuniqueptr in GalleryThemeCacheEntry
Change-Id: Ib9f3e604ca889a938cd41dbf3f59dfa7131fe4da
Reviewed-on: https://gerrit.libreoffice.org/59352
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 87a8c7d3e611..813eff0a563e 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -242,8 +242,8 @@ private: public: - GalleryThemeCacheEntry( const GalleryThemeEntry* pThemeEntry, GalleryTheme* pTheme ) : - mpThemeEntry( pThemeEntry ), mpTheme( pTheme ) {} + GalleryThemeCacheEntry( const GalleryThemeEntry* pThemeEntry, std::unique_ptr<GalleryTheme> pTheme ) : + mpThemeEntry( pThemeEntry ), mpTheme( std::move(pTheme) ) {} const GalleryThemeEntry* GetThemeEntry() const { return mpThemeEntry; } GalleryTheme* GetTheme() const { return mpTheme.get(); } @@ -703,6 +703,7 @@ GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); + std::unique_ptr<GalleryTheme> pNewTheme; if( FileExists( aURL ) ) { std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ )); @@ -711,14 +712,11 @@ GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) { try { - pTheme = new GalleryTheme( this, const_cast<GalleryThemeEntry*>(pThemeEntry) ); - ReadGalleryTheme( *pIStm, *pTheme ); + pNewTheme.reset( new GalleryTheme( this, const_cast<GalleryThemeEntry*>(pThemeEntry) ) ); + ReadGalleryTheme( *pIStm, *pNewTheme ); if( pIStm->GetError() ) - { - delete pTheme; - pTheme = nullptr; - } + pNewTheme.reset(); } catch (const css::ucb::ContentCreationException&) { @@ -726,8 +724,9 @@ GalleryTheme* Gallery::ImplGetCachedTheme(const GalleryThemeEntry* pThemeEntry) } } + pTheme = pNewTheme.get(); if( pTheme ) - aThemeCache.push_back( new GalleryThemeCacheEntry( pThemeEntry, pTheme )); + aThemeCache.push_back( new GalleryThemeCacheEntry( pThemeEntry, std::move(pNewTheme) )); } } |