From ee3898f9a167a9d876b49d38f57f2b455cf28b48 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 2 May 2018 14:26:51 +0200 Subject: loplugin:useuniqueptr in ImageManagerImpl Change-Id: I686d68ccee120246c20c2c52977422f49a318af9 Reviewed-on: https://gerrit.libreoffice.org/53762 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/uiconfiguration/imagemanagerimpl.cxx | 25 +++++++++------------- .../source/uiconfiguration/imagemanagerimpl.hxx | 4 ++-- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'framework') 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 m_pDefaultImageList; OUString m_aModuleIdentifier; OUString m_aResourceString; osl::Mutex m_mutex; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener - o3tl::enumarray m_pUserImageList; + o3tl::enumarray> m_pUserImageList; o3tl::enumarray m_bUserImageListModified; bool m_bUseGlobal; bool m_bReadOnly; -- cgit