summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-09 17:10:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-10 08:30:21 +0200
commit65e41592a650887c8d00586385119effa54de5fa (patch)
tree4b0f6c7f52159d9cf70c561c815f623d3b57198d /forms
parentacb7c06ab171d4201842d8183eefeeca2d28c3f5 (diff)
pass SvStream around by std::unique_ptr
and give utl::OStreamWrapper a new constructor so that it knows it is taking ownership of the SvStream, which appears to fix several leaks Change-Id: Idcbcca9b81a4f0345fd8b8c8a2f4e84213686a6b Reviewed-on: https://gerrit.libreoffice.org/57187 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/DatabaseForm.cxx9
-rw-r--r--forms/source/component/ImageControl.cxx2
-rw-r--r--forms/source/component/imgprod.cxx4
-rw-r--r--forms/source/richtext/richtextvclcontrol.cxx3
4 files changed, 8 insertions, 10 deletions
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 4d7cc390171a..0808b029edf7 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -963,7 +963,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
{
OUString aFileName(rFileName);
OUString aContentType(CONTENT_TYPE_STR_TEXT_PLAIN);
- SvStream *pStream = nullptr;
+ std::unique_ptr<SvStream> pStream;
if (!aFileName.isEmpty())
{
@@ -977,8 +977,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
pStream = ::utl::UcbStreamHelper::CreateStream(aFileName, StreamMode::READ);
if (!pStream || (pStream->GetError() != ERRCODE_NONE))
{
- delete pStream;
- pStream = nullptr;
+ pStream.reset();
}
sal_Int32 nSepInd = aFileName.lastIndexOf('.');
OUString aExtension = aFileName.copy( nSepInd + 1 );
@@ -990,7 +989,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
// If something didn't work, we create an empty MemoryStream
if( !pStream )
- pStream = new SvMemoryStream;
+ pStream.reset( new SvMemoryStream );
// Create part as MessageChild
@@ -1013,7 +1012,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN
// Body
- pChild->SetDocumentLB( new SvLockBytes(pStream, true) );
+ pChild->SetDocumentLB( new SvLockBytes(pStream.release(), true) );
rParent.AttachChild( std::move(pChild) );
return true;
diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx
index b75b08270334..0db96134a902 100644
--- a/forms/source/component/ImageControl.cxx
+++ b/forms/source/component/ImageControl.cxx
@@ -400,7 +400,7 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val
}
else
{
- pImageStream.reset( ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ ) );
+ pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, StreamMode::READ );
bool bSetNull = ( pImageStream.get() == nullptr ) || ( ERRCODE_NONE != pImageStream->GetErrorCode() );
if ( !bSetNull )
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx
index 0b55ecd942f1..9e2700f0b971 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -209,9 +209,9 @@ void ImageProducer::SetImage( const OUString& rPath )
}
else if( !maURL.isEmpty() )
{
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ );
+ std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ );
if (pIStm)
- mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm, true ) ) );
+ mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm.release(), true ) ) );
}
}
diff --git a/forms/source/richtext/richtextvclcontrol.cxx b/forms/source/richtext/richtextvclcontrol.cxx
index fd466cf25b2c..e5f0848eebf4 100644
--- a/forms/source/richtext/richtextvclcontrol.cxx
+++ b/forms/source/richtext/richtextvclcontrol.cxx
@@ -246,7 +246,7 @@ namespace frm
if ( nResult == ERRCODE_NONE )
{
OUString sFileName = aFP.GetPath();
- SvStream* pStream = ::utl::UcbStreamHelper::CreateStream(
+ std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream(
sFileName, ( bLoad ? StreamMode::READ : StreamMode::WRITE | StreamMode::TRUNC ) | StreamMode::SHARE_DENYALL
);
if ( pStream )
@@ -272,7 +272,6 @@ namespace frm
getEngine().Write( *pStream, eFormat );
}
}
- DELETEZ( pStream );
}
return true; // handled
}