summaryrefslogtreecommitdiff
path: root/sd
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 /sd
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 'sd')
-rw-r--r--sd/source/core/CustomAnimationPreset.cxx4
-rw-r--r--sd/source/filter/eppt/pptexsoundcollection.cxx3
-rw-r--r--sd/source/filter/html/htmlex.cxx6
-rw-r--r--sd/source/filter/html/pubdlg.cxx4
-rw-r--r--sd/source/filter/ppt/pptin.cxx4
-rw-r--r--sd/source/ui/app/sdmod.cxx4
-rw-r--r--sd/source/ui/app/sdxfer.cxx4
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.cxx3
8 files changed, 13 insertions, 19 deletions
diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index e420c5885800..9eac96516f82 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -244,8 +244,8 @@ Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFac
try
{
// create stream
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rPath, StreamMode::READ );
- Reference<XInputStream> xInputStream( new utl::OInputStreamWrapper( pIStm, true ) );
+ std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( rPath, StreamMode::READ );
+ Reference<XInputStream> xInputStream( new utl::OInputStreamWrapper( std::move(pIStm) ) );
// prepare ParserInputSrouce
xml::sax::InputSource aParserInput;
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx b/sd/source/filter/eppt/pptexsoundcollection.cxx
index 287853b05c51..8a3330237fa0 100644
--- a/sd/source/filter/eppt/pptexsoundcollection.cxx
+++ b/sd/source/filter/eppt/pptexsoundcollection.cxx
@@ -127,7 +127,7 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) const
rSt.WriteUInt32( EPP_SoundData << 16 ).WriteUInt32( nFileSize );
sal_uInt32 nBytesLeft = nFileSize;
- SvStream* pSourceFile = ::utl::UcbStreamHelper::CreateStream( aSoundURL, StreamMode::READ );
+ std::unique_ptr<SvStream> pSourceFile = ::utl::UcbStreamHelper::CreateStream( aSoundURL, StreamMode::READ );
if ( pSourceFile )
{
std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ 0x10000 ] ); // 64 kB Buffer
@@ -138,7 +138,6 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) const
rSt.WriteBytes(pBuf.get(), nToDo);
nBytesLeft -= nToDo;
}
- delete pSourceFile;
}
}
catch( css::uno::Exception& )
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index 0e47c46add57..b0a6dd8c2e04 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -2866,7 +2866,7 @@ bool HtmlExport::CopyScript( const OUString& rPath, const OUString& rSource, con
meEC.SetContext( STR_HTMLEXP_ERROR_OPEN_FILE, rSource );
ErrCode nErr = ERRCODE_NONE;
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
+ std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
if( pIStm )
{
@@ -2886,7 +2886,7 @@ bool HtmlExport::CopyScript( const OUString& rPath, const OUString& rSource, con
}
nErr = pIStm->GetError();
- delete pIStm;
+ pIStm.reset();
}
if( nErr != ERRCODE_NONE )
@@ -3141,7 +3141,7 @@ ErrCode EasyFile::createStream( const OUString& rUrl, SvStream* &rpStr )
createFileName( rUrl, aFileName );
ErrCode nErr = ERRCODE_NONE;
- pOStm.reset( ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE | StreamMode::TRUNC ) );
+ pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE | StreamMode::TRUNC );
if( pOStm )
{
bOpen = true;
diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx
index 538eb71e57bd..79df8be785cf 100644
--- a/sd/source/filter/html/pubdlg.cxx
+++ b/sd/source/filter/html/pubdlg.cxx
@@ -1514,12 +1514,10 @@ void SdPublishingDlg::Load()
// check if file exists, SfxMedium shows an errorbox else
{
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
+ std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE);
- delete pIStm;
-
if( !bOk )
return;
}
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index ab97f71ce73d..364c07662181 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1961,7 +1961,7 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
std::vector<sal_uInt8> aBuf(nSoundDataLen);
rStCtrl.ReadBytes(aBuf.data(), nSoundDataLen);
- SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC );
+ std::unique_ptr<SvStream> pOStm = ::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC );
if( pOStm )
{
@@ -1972,8 +1972,6 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aGalleryUserSound.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
aRetval = aGalleryUserSound.GetMainURL( INetURLObject::DecodeMechanism::NONE );
}
-
- delete pOStm;
}
}
}
diff --git a/sd/source/ui/app/sdmod.cxx b/sd/source/ui/app/sdmod.cxx
index c519302a8fa5..b55213c44ed2 100644
--- a/sd/source/ui/app/sdmod.cxx
+++ b/sd/source/ui/app/sdmod.cxx
@@ -183,10 +183,10 @@ tools::SvRef<SotStorageStream> SdModule::GetOptionStream( const OUString& rOptio
aURL.Append( "drawing.cfg" );
- SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE );
+ std::unique_ptr<SvStream> pStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE );
if( pStm )
- xOptionStorage = new SotStorage( pStm, true );
+ xOptionStorage = new SotStorage( pStm.release(), true );
}
OUString aStmName;
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index a8118228cc9e..7523b53af472 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -640,12 +640,12 @@ bool SdTransferable::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void*
if ( xTransact.is() )
xTransact->commit();
- SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
+ std::unique_ptr<SvStream> pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
if( pSrcStm )
{
rxOStm->SetBufferSize( 0xff00 );
rxOStm->WriteStream( *pSrcStm );
- delete pSrcStm;
+ pSrcStm.reset();
}
bRet = true;
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index bd14bce7f6fe..1f728df73aa8 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -610,13 +610,12 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, weld::TreeView&, void)
// remote?
if ( INetProtocol::File != aURLObj.GetProtocol() )
{
- SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( sImgUrl, StreamMode::READ );
+ std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream( sImgUrl, StreamMode::READ );
if( pStream )
m_pGraphicFilter->ImportGraphic( aGraphic, sImgUrl, *pStream, nFilter, nullptr, nFilterImportFlags );
else
m_pGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, nullptr, nFilterImportFlags );
- delete pStream;
}
else
{