[Libreoffice-commits] core.git: unotools/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Feb 11 07:55:11 UTC 2016


 unotools/source/ucbhelper/XTempFile.hxx |    3 ++-
 unotools/source/ucbhelper/xtempfile.cxx |   13 +++----------
 2 files changed, 5 insertions(+), 11 deletions(-)

New commits:
commit ed21ac627cecc7dd7f416462beb6cf099889e79f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 11 08:54:17 2016 +0100

    OTempFileService: avoid manually deleting mpTempFile
    
    Change-Id: Ic2f83fd4ff83795a77dd9b97b98e2635e5c447c0

diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx
index 5d54883..f50aeea 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 <memory>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <com/sun/star/io/XSeekable.hpp>
@@ -44,7 +45,7 @@ class OTempFileService : public OTempFileBase
     , public ::cppu::PropertySetMixin< css::io::XTempFile >
 {
 protected:
-    ::utl::TempFile* mpTempFile;
+    std::unique_ptr<utl::TempFile> mpTempFile;
     ::osl::Mutex maMutex;
     SvStream* mpStream;
     bool mbRemoveFile;
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index 888ee86..e0afe6b 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);
     }
 }
 


More information about the Libreoffice-commits mailing list