From 0d46a29b2144eb840935e6bb040ee016d74b4d99 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 23 Aug 2017 15:05:45 +0200 Subject: loplugin:useuniqueptr in forms Change-Id: I656ef57a322a4d04d0a39ae8f9e1df6fff054a58 Reviewed-on: https://gerrit.libreoffice.org/41511 Tested-by: Jenkins Reviewed-by: Noel Grandin --- forms/source/component/imgprod.cxx | 27 +++++++++------------------ forms/source/component/imgprod.hxx | 7 +++++-- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'forms') diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 1f7eb6045500..154b4114800c 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -161,16 +161,11 @@ ImageProducer::ImageProducer() , mnTransIndex(0) , mbConsInit(false) { - mpGraphic = new Graphic; + mpGraphic.reset( new Graphic ); } ImageProducer::~ImageProducer() { - delete mpGraphic; - mpGraphic = nullptr; - - delete mpStm; - mpStm = nullptr; } @@ -206,19 +201,18 @@ void ImageProducer::SetImage( const OUString& rPath ) maURL = rPath; mpGraphic->Clear(); mbConsInit = false; - delete mpStm; + mpStm.reset(); if ( ::svt::GraphicAccess::isSupportedURL( maURL ) ) { - mpStm = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ); + mpStm.reset( ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ) ); } else if( !maURL.isEmpty() ) { SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ ); - mpStm = pIStm ? new SvStream( new ImgProdLockBytes( pIStm, true ) ) : nullptr; + if (pIStm) + mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm, true ) ) ); } - else - mpStm = nullptr; } @@ -228,8 +222,7 @@ void ImageProducer::SetImage( SvStream& rStm ) mpGraphic->Clear(); mbConsInit = false; - delete mpStm; - mpStm = new SvStream( new ImgProdLockBytes( &rStm, false ) ); + mpStm.reset( new SvStream( new ImgProdLockBytes( &rStm, false ) ) ); } @@ -238,12 +231,10 @@ void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const maURL.clear(); mpGraphic->Clear(); mbConsInit = false; - delete mpStm; + mpStm.reset(); if( rInputStmRef.is() ) - mpStm = new SvStream( new ImgProdLockBytes( rInputStmRef ) ); - else - mpStm = nullptr; + mpStm.reset( new SvStream( new ImgProdLockBytes( rInputStmRef ) ) ); } @@ -268,7 +259,7 @@ void ImageProducer::startProduction() if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetContext() ) { if ( ImplImportGraphic( *mpGraphic ) ) - maDoneHdl.Call( mpGraphic ); + maDoneHdl.Call( mpGraphic.get() ); } if( mpGraphic->GetType() != GraphicType::NONE ) diff --git a/forms/source/component/imgprod.hxx b/forms/source/component/imgprod.hxx index a247b2890f92..2c0fed6e2c44 100644 --- a/forms/source/component/imgprod.hxx +++ b/forms/source/component/imgprod.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -47,8 +48,10 @@ private: OUString maURL; ConsumerList_t maConsList; - Graphic* mpGraphic; - SvStream* mpStm; + std::unique_ptr + mpGraphic; + std::unique_ptr + mpStm; sal_uInt32 mnTransIndex; bool mbConsInit; Link maDoneHdl; -- cgit