diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-02 14:26:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-03 08:24:54 +0200 |
commit | ee3898f9a167a9d876b49d38f57f2b455cf28b48 (patch) | |
tree | ae0b1aaece44d6f3ddb5fc68e2fc7d967cdd2e5c /framework | |
parent | 12c0aaf4aea8cdd6fbabd4f04228fb40e0220067 (diff) |
loplugin:useuniqueptr in ImageManagerImpl
Change-Id: I686d68ccee120246c20c2c52977422f49a318af9
Reviewed-on: https://gerrit.libreoffice.org/53762
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.cxx | 25 | ||||
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.hxx | 4 |
2 files changed, 12 insertions, 17 deletions
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 080ac0db8aa7..dfaf13572044 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -271,7 +271,7 @@ ImageList* ImageManagerImpl::implts_getUserImageList( vcl::ImageType nImageType if ( !m_pUserImageList[nImageType] ) implts_loadUserImages( nImageType, m_xUserImageStorage, m_xUserBitmapsStorage ); - return m_pUserImageList[nImageType]; + return m_pUserImageList[nImageType].get(); } void ImageManagerImpl::implts_initialize() @@ -355,8 +355,7 @@ bool ImageManagerImpl::implts_loadUserImages( } // Delete old image list and create a new one from the read bitmap - delete m_pUserImageList[nImageType]; - m_pUserImageList[nImageType] = new ImageList(); + m_pUserImageList[nImageType].reset(new ImageList()); m_pUserImageList[nImageType]->InsertFromHorizontalStrip ( aUserBitmap, aUserImagesVector ); return true; @@ -381,8 +380,7 @@ bool ImageManagerImpl::implts_loadUserImages( } // Destroy old image list - create a new empty one - delete m_pUserImageList[nImageType]; - m_pUserImageList[nImageType] = new ImageList; + m_pUserImageList[nImageType].reset(new ImageList); return true; } @@ -504,9 +502,9 @@ CmdImageList* ImageManagerImpl::implts_getDefaultImageList() SolarMutexGuard g; if ( !m_pDefaultImageList ) - m_pDefaultImageList = new CmdImageList( m_xContext, m_aModuleIdentifier ); + m_pDefaultImageList.reset(new CmdImageList( m_xContext, m_aModuleIdentifier )); - return m_pDefaultImageList; + return m_pDefaultImageList.get(); } ImageManagerImpl::ImageManagerImpl( const uno::Reference< uno::XComponentContext >& rxContext,::cppu::OWeakObject* pOwner,bool _bUseGlobal ) : @@ -548,13 +546,11 @@ void ImageManagerImpl::dispose() m_bDisposed = true; // delete user and default image list on dispose - for (ImageList*& n : m_pUserImageList) + for (auto& n : m_pUserImageList) { - delete n; - n = nullptr; + n.reset(); } - delete m_pDefaultImageList; - m_pDefaultImageList = nullptr; + m_pDefaultImageList.reset(); } } @@ -1234,10 +1230,9 @@ void ImageManagerImpl::clear() { SolarMutexGuard g; - for (ImageList* & n : m_pUserImageList) + for (auto & n : m_pUserImageList) { - delete n; - n = nullptr; + n.reset(); } } } // namespace framework diff --git a/framework/source/uiconfiguration/imagemanagerimpl.hxx b/framework/source/uiconfiguration/imagemanagerimpl.hxx index 34cc99dd2f53..21b4ac342a2d 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.hxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.hxx @@ -177,12 +177,12 @@ namespace framework css::uno::Reference< css::uno::XComponentContext > m_xContext; ::cppu::OWeakObject* m_pOwner; rtl::Reference< GlobalImageList > m_pGlobalImageList; - CmdImageList* m_pDefaultImageList; + std::unique_ptr<CmdImageList> m_pDefaultImageList; OUString m_aModuleIdentifier; OUString m_aResourceString; osl::Mutex m_mutex; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener - o3tl::enumarray<vcl::ImageType,ImageList*> m_pUserImageList; + o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>> m_pUserImageList; o3tl::enumarray<vcl::ImageType,bool> m_bUserImageListModified; bool m_bUseGlobal; bool m_bReadOnly; |