From cfb598178b2b38023c9237578904303bea7962e7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 17 Jan 2018 13:24:50 +0200 Subject: loplugin:useuniqueptr in ImageListsDescriptor Change-Id: I165af348b6d8863a4b1e5dd164d92c29f49d09c0 Reviewed-on: https://gerrit.libreoffice.org/48423 Tested-by: Jenkins Reviewed-by: Noel Grandin --- framework/inc/xml/imagesconfiguration.hxx | 8 +++----- framework/source/uiconfiguration/imagemanagerimpl.cxx | 2 +- framework/source/xml/imagesdocumenthandler.cxx | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'framework') diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx index 68291bea7a26..1ead958915cc 100644 --- a/framework/inc/xml/imagesconfiguration.hxx +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -76,12 +76,10 @@ typedef std::vector > ImageListDescript struct ImageListsDescriptor { - ImageListsDescriptor() : pImageList( nullptr ), - pExternalImageList( nullptr ) {} - ~ImageListsDescriptor() { delete pImageList; delete pExternalImageList; } + ImageListsDescriptor() {} - ImageListDescriptor* pImageList; - ExternalImageItemListDescriptor* pExternalImageList; + std::unique_ptr pImageList; + std::unique_ptr pExternalImageList; }; class ImagesConfiguration diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index f47666b5270f..ee88e2756541 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -400,7 +400,7 @@ bool ImageManagerImpl::implts_storeUserImages( if ( pImageList->GetImageCount() > 0 ) { ImageListsDescriptor aUserImageListInfo; - aUserImageListInfo.pImageList = new ImageListDescriptor; + aUserImageListInfo.pImageList.reset( new ImageListDescriptor ); ImageListItemDescriptor* pList = new ImageListItemDescriptor; aUserImageListInfo.pImageList->push_back( std::unique_ptr(pList) ); diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx index cc0278807052..327e666fde9d 100644 --- a/framework/source/xml/imagesdocumenthandler.cxx +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -197,7 +197,7 @@ void SAL_CALL OReadImagesDocumentHandler::startElement( } if ( !m_aImageList.pImageList ) - m_aImageList.pImageList = new ImageListDescriptor; + m_aImageList.pImageList.reset( new ImageListDescriptor ); m_bImagesStartFound = true; m_pImages = new ImageListItemDescriptor; @@ -511,7 +511,7 @@ void SAL_CALL OReadImagesDocumentHandler::endElement(const OUString& aName) if ( m_pExternalImages && !m_aImageList.pExternalImageList ) { if ( !m_aImageList.pExternalImageList ) - m_aImageList.pExternalImageList = m_pExternalImages; + m_aImageList.pExternalImageList.reset( m_pExternalImages ); } m_bExternalImagesStartFound = false; @@ -614,7 +614,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() if ( m_aImageListsItems.pImageList ) { - ImageListDescriptor* pImageList = m_aImageListsItems.pImageList; + ImageListDescriptor* pImageList = m_aImageListsItems.pImageList.get(); for ( size_t i = 0; i < m_aImageListsItems.pImageList->size(); i++ ) { @@ -625,7 +625,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument() if ( m_aImageListsItems.pExternalImageList ) { - WriteExternalImageList( m_aImageListsItems.pExternalImageList ); + WriteExternalImageList( m_aImageListsItems.pExternalImageList.get() ); } m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); -- cgit