summaryrefslogtreecommitdiff
path: root/svtools
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 /svtools
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 'svtools')
-rw-r--r--svtools/source/misc/embedhlp.cxx7
-rw-r--r--svtools/source/misc/embedtransfer.cxx2
-rw-r--r--svtools/source/misc/templatefoldercache.cxx4
3 files changed, 6 insertions, 7 deletions
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 0d83432d15f9..b6ec9ae1576d 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -545,7 +545,7 @@ void EmbeddedObjectRef::SetGraphic( const Graphic& rGraphic, const OUString& rMe
mpImpl->bNeedUpdate = false;
}
-SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
+std::unique_ptr<SvStream> EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
{
DBG_ASSERT( bUpdate || mpImpl->pContainer, "Can't retrieve current graphic!" );
uno::Reference < io::XInputStream > xStream;
@@ -557,7 +557,7 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
if ( xStream.is() )
{
const sal_Int32 nConstBufferSize = 32000;
- SvStream *pStream = new SvMemoryStream( 32000, 32000 );
+ std::unique_ptr<SvStream> pStream(new SvMemoryStream( 32000, 32000 ));
try
{
sal_Int32 nRead=0;
@@ -574,7 +574,6 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
catch (const uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION("svtools.misc", "discarding broken embedded object preview");
- delete pStream;
xStream.clear();
}
}
@@ -607,7 +606,7 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
if (mpImpl->pContainer)
mpImpl->pContainer->InsertGraphicStream(xStream,mpImpl->aPersistName,mpImpl->aMediaType);
- SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
+ std::unique_ptr<SvStream> pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
if (pResult && bUpdate)
mpImpl->bNeedUpdate = false;
diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx
index 51c16627e338..29e894c56bd1 100644
--- a/svtools/source/misc/embedtransfer.cxx
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -117,7 +117,7 @@ bool SvEmbedTransferHelper::GetData( const css::datatransfer::DataFlavor& rFlavo
if ( xStg->isStreamElement( aName ) )
{
uno::Reference < io::XStream > xStm = xStg->cloneStreamElement( aName );
- pStream = utl::UcbStreamHelper::CreateStream( xStm );
+ pStream = utl::UcbStreamHelper::CreateStream( xStm ).release();
bDeleteStream = true;
}
else
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
index 41141d1ba0c9..6fd4f6944ee7 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -702,8 +702,8 @@ namespace svt
aStorageURL.Append( ".templdir.cache" );
// open the stream
- m_pCacheStream.reset( UcbStreamHelper::CreateStream( aStorageURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),
- _bForRead ? StreamMode::READ | StreamMode::NOCREATE : StreamMode::WRITE | StreamMode::TRUNC ) );
+ m_pCacheStream = UcbStreamHelper::CreateStream( aStorageURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),
+ _bForRead ? StreamMode::READ | StreamMode::NOCREATE : StreamMode::WRITE | StreamMode::TRUNC );
DBG_ASSERT( m_pCacheStream, "TemplateFolderCacheImpl::openCacheStream: could not open/create the cache stream!" );
if ( m_pCacheStream && m_pCacheStream->GetErrorCode() )
{