diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-09 17:10:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-10 08:30:21 +0200 |
commit | 65e41592a650887c8d00586385119effa54de5fa (patch) | |
tree | 4b0f6c7f52159d9cf70c561c815f623d3b57198d /include/unotools | |
parent | acb7c06ab171d4201842d8183eefeeca2d28c3f5 (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 'include/unotools')
-rw-r--r-- | include/unotools/streamwrap.hxx | 3 | ||||
-rw-r--r-- | include/unotools/ucbstreamhelper.hxx | 15 |
2 files changed, 11 insertions, 7 deletions
diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx index 81f463ea6e2c..299b6dfd081f 100644 --- a/include/unotools/streamwrap.hxx +++ b/include/unotools/streamwrap.hxx @@ -29,6 +29,7 @@ #include <com/sun/star/io/XStream.hpp> #include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase1.hxx> +#include <memory> class SvStream; @@ -53,6 +54,7 @@ protected: public: OInputStreamWrapper(SvStream& _rStream); OInputStreamWrapper(SvStream* pStream, bool bOwner=false); + OInputStreamWrapper(std::unique_ptr<SvStream> pStream); virtual ~OInputStreamWrapper() override; // css::io::XInputStream @@ -152,6 +154,7 @@ protected: public: OStreamWrapper(SvStream& _rStream); + OStreamWrapper(std::unique_ptr<SvStream> _rStream); // css::io::XStream virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream( ) override; diff --git a/include/unotools/ucbstreamhelper.hxx b/include/unotools/ucbstreamhelper.hxx index 68309d094acf..f037571fe212 100644 --- a/include/unotools/ucbstreamhelper.hxx +++ b/include/unotools/ucbstreamhelper.hxx @@ -25,6 +25,7 @@ #include <unotools/unotoolsdllapi.h> #include <tools/stream.hxx> +#include <memory> namespace com { @@ -52,13 +53,13 @@ namespace utl class UNOTOOLS_DLLPUBLIC UcbStreamHelper { public: - static SvStream* CreateStream( const OUString& rFileName, StreamMode eOpenMode ); - static SvStream* CreateStream( const OUString& rFileName, StreamMode eOpenMode, - bool bFileExists ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XStream >& xStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XStream >& xStream, bool bCloseStream ); + static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode ); + static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode, + bool bFileExists ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream, bool bCloseStream ); }; } |