From ed21ac627cecc7dd7f416462beb6cf099889e79f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 11 Feb 2016 08:54:17 +0100 Subject: OTempFileService: avoid manually deleting mpTempFile Change-Id: Ic2f83fd4ff83795a77dd9b97b98e2635e5c447c0 --- unotools/source/ucbhelper/XTempFile.hxx | 3 ++- unotools/source/ucbhelper/xtempfile.cxx | 13 +++---------- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'unotools') diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx index 5d54883bfeb8..f50aeea3c98e 100644 --- a/unotools/source/ucbhelper/XTempFile.hxx +++ b/unotools/source/ucbhelper/XTempFile.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_UNOTOOLS_SOURCE_UCBHELPER_XTEMPFILE_HXX #define INCLUDED_UNOTOOLS_SOURCE_UCBHELPER_XTEMPFILE_HXX +#include #include #include #include @@ -44,7 +45,7 @@ class OTempFileService : public OTempFileBase , public ::cppu::PropertySetMixin< css::io::XTempFile > { protected: - ::utl::TempFile* mpTempFile; + std::unique_ptr mpTempFile; ::osl::Mutex maMutex; SvStream* mpStream; bool mbRemoveFile; diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx index 888ee864c850..e0afe6b107e5 100644 --- a/unotools/source/ucbhelper/xtempfile.cxx +++ b/unotools/source/ucbhelper/xtempfile.cxx @@ -39,13 +39,12 @@ OTempFileService::OTempFileService(css::uno::Reference< css::uno::XComponentCont , mbHasCachedPos( false ) { - mpTempFile = new ::utl::TempFile; + mpTempFile.reset(new utl::TempFile()); mpTempFile->EnableKillingFile(); } OTempFileService::~OTempFileService () { - delete mpTempFile; } // XInterface @@ -248,10 +247,7 @@ throw ( css::io::NotConnectedException, css::io::IOException, css::uno::RuntimeE mpStream = nullptr; if ( mpTempFile ) - { - delete mpTempFile; - mpTempFile = nullptr; - } + mpTempFile.reset(nullptr); } } @@ -307,10 +303,7 @@ throw ( css::io::NotConnectedException, css::io::BufferSizeExceededException, cs mpStream = nullptr; if ( mpTempFile ) - { - delete mpTempFile; - mpTempFile = nullptr; - } + mpTempFile.reset(nullptr); } } -- cgit v1.2.3