summaryrefslogtreecommitdiff
path: root/vcl/source/graphic/UnoGraphicProvider.cxx
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 /vcl/source/graphic/UnoGraphicProvider.cxx
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 'vcl/source/graphic/UnoGraphicProvider.cxx')
-rw-r--r--vcl/source/graphic/UnoGraphicProvider.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx
index bf0b0bc8f654..5b28ed3723c5 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -366,7 +366,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
if( xIStm.is() )
{
- pIStm.reset(::utl::UcbStreamHelper::CreateStream( xIStm ));
+ pIStm = ::utl::UcbStreamHelper::CreateStream( xIStm );
}
else if( !aPath.isEmpty() )
{
@@ -379,7 +379,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
xRet = implLoadStandardImage( aPath );
if( !xRet.is() )
- pIStm.reset(::utl::UcbStreamHelper::CreateStream( aPath, StreamMode::READ ));
+ pIStm = ::utl::UcbStreamHelper::CreateStream( aPath, StreamMode::READ );
}
else if( xBtm.is() )
{
@@ -441,10 +441,10 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::que
SolarMutexGuard aGuard;
// Turn properties into streams.
- std::vector< std::shared_ptr<SvStream> > aStreams;
+ std::vector< std::unique_ptr<SvStream> > aStreams;
for (const auto& rMediaProperties : rMediaPropertiesSeq)
{
- SvStream* pStream = nullptr;
+ std::unique_ptr<SvStream> pStream;
uno::Reference<io::XInputStream> xStream;
for (sal_Int32 i = 0; rMediaProperties.getLength(); ++i)
@@ -458,14 +458,13 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::que
}
}
- aStreams.push_back(std::shared_ptr<SvStream>(pStream));
-
+ aStreams.push_back(std::move(pStream));
}
// Import: streams to graphics.
std::vector< std::shared_ptr<Graphic> > aGraphics;
GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
- rFilter.ImportGraphics(aGraphics, aStreams);
+ rFilter.ImportGraphics(aGraphics, std::move(aStreams));
// Returning: graphics to UNO objects.
std::vector< uno::Reference<graphic::XGraphic> > aRet;
@@ -718,7 +717,7 @@ void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XG
OUString aURL;
aValue >>= aURL;
- pOStm.reset(::utl::UcbStreamHelper::CreateStream( aURL, StreamMode::WRITE | StreamMode::TRUNC ));
+ pOStm = ::utl::UcbStreamHelper::CreateStream( aURL, StreamMode::WRITE | StreamMode::TRUNC );
aPath = aURL;
}
else if (aName == "OutputStream")
@@ -728,7 +727,7 @@ void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XG
aValue >>= xOStm;
if( xOStm.is() )
- pOStm.reset(::utl::UcbStreamHelper::CreateStream( xOStm ));
+ pOStm = ::utl::UcbStreamHelper::CreateStream( xOStm );
}
}