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

Noel Grandin noel.grandin at collabora.co.uk
Wed Dec 13 19:12:39 UTC 2017


 include/toolkit/controls/unocontrol.hxx          |    3 ++-
 include/toolkit/controls/unocontrolcontainer.hxx |    3 ++-
 toolkit/source/controls/unocontrol.cxx           |    1 -
 toolkit/source/controls/unocontrolcontainer.cxx  |    8 +++-----
 unotools/source/config/saveopt.cxx               |   18 ++++++++----------
 5 files changed, 15 insertions(+), 18 deletions(-)

New commits:
commit 78a6ce17f06fbe13b806fd563e85a4fe60d3bcfc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Dec 13 15:47:02 2017 +0200

    DELETEZ->std::unique_ptr in toolkit,unotools
    
    Change-Id: I2263e233ae03575e53ab4e7894a7507423afd32e
    Reviewed-on: https://gerrit.libreoffice.org/46397
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/toolkit/controls/unocontrol.hxx b/include/toolkit/controls/unocontrol.hxx
index 9080d918304e..29dd824f88bc 100644
--- a/include/toolkit/controls/unocontrol.hxx
+++ b/include/toolkit/controls/unocontrol.hxx
@@ -41,6 +41,7 @@
 #include <cppuhelper/implbase9.hxx>
 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
 #include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <memory>
 
 
 struct UnoControlComponentInfos
@@ -108,7 +109,7 @@ protected:
     bool                            mbDesignMode;
 
     UnoControlComponentInfos            maComponentInfos;
-    UnoControl_Data*                    mpData;
+    std::unique_ptr<UnoControl_Data>    mpData;
 
     ::osl::Mutex&                                                               GetMutex() { return maMutex; }
 
diff --git a/include/toolkit/controls/unocontrolcontainer.hxx b/include/toolkit/controls/unocontrolcontainer.hxx
index ca2a5a54555b..816632d418db 100644
--- a/include/toolkit/controls/unocontrolcontainer.hxx
+++ b/include/toolkit/controls/unocontrolcontainer.hxx
@@ -32,6 +32,7 @@
 #include <toolkit/helper/servicenames.hxx>
 
 #include <cppuhelper/implbase4.hxx>
+#include <memory>
 
 class UnoControlHolderList;
 
@@ -48,7 +49,7 @@ typedef ::cppu::AggImplInheritanceHelper4   <   UnoControlBase
 class UnoControlContainer : public UnoControlContainer_Base
 {
 private:
-    UnoControlHolderList*                   mpControls;
+    std::unique_ptr<UnoControlHolderList>   mpControls;
     css::uno::Sequence< css::uno::Reference< css::awt::XTabController > >    maTabControllers;
     ContainerListenerMultiplexer            maCListeners;
 
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index f07ff4d64251..6c8435791883 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -150,7 +150,6 @@ UnoControl::UnoControl() :
 
 UnoControl::~UnoControl()
 {
-    DELETEZ( mpData );
 }
 
 OUString UnoControl::GetComponentServiceName()
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index 0a992812f7d8..5b533dddb22a 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -381,7 +381,7 @@ UnoControlContainer::UnoControlContainer()
     :UnoControlContainer_Base()
     ,maCListeners( *this )
 {
-    mpControls = new UnoControlHolderList;
+    mpControls.reset(new UnoControlHolderList);
 }
 
 UnoControlContainer::UnoControlContainer(const uno::Reference< awt::XWindowPeer >& xP )
@@ -390,12 +390,11 @@ UnoControlContainer::UnoControlContainer(const uno::Reference< awt::XWindowPeer
 {
     setPeer( xP );
     mbDisposePeer = false;
-    mpControls = new UnoControlHolderList;
+    mpControls.reset(new UnoControlHolderList);
 }
 
 UnoControlContainer::~UnoControlContainer()
 {
-    DELETEZ( mpControls );
 }
 
 void UnoControlContainer::ImplActivateTabControllers()
@@ -433,8 +432,7 @@ void UnoControlContainer::dispose(  )
 
 
     // Delete all structures
-    DELETEZ( mpControls );
-    mpControls = new UnoControlHolderList;
+    mpControls.reset(new UnoControlHolderList);
 
     UnoControlBase::dispose();
 }
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index cdb66c6fabe4..35b721702f21 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -45,11 +45,11 @@ class SvtLoadOptions_Impl;
 
 struct SvtLoadSaveOptions_Impl
 {
-    SvtSaveOptions_Impl* pSaveOpt;
-    SvtLoadOptions_Impl* pLoadOpt;
+    std::unique_ptr<SvtSaveOptions_Impl> pSaveOpt;
+    std::unique_ptr<SvtLoadOptions_Impl> pLoadOpt;
 };
 
-static SvtLoadSaveOptions_Impl* pOptions = nullptr;
+static std::unique_ptr<SvtLoadSaveOptions_Impl> pOptions;
 static sal_Int32           nRefCount = 0;
 
 class SvtSaveOptions_Impl : public utl::ConfigItem
@@ -802,14 +802,14 @@ SvtSaveOptions::SvtSaveOptions()
     ::osl::MutexGuard aGuard( LocalSingleton::get() );
     if ( !pOptions )
     {
-        pOptions = new SvtLoadSaveOptions_Impl;
-        pOptions->pSaveOpt = new SvtSaveOptions_Impl;
-        pOptions->pLoadOpt = new SvtLoadOptions_Impl;
+        pOptions.reset(new SvtLoadSaveOptions_Impl);
+        pOptions->pSaveOpt.reset(new SvtSaveOptions_Impl);
+        pOptions->pLoadOpt.reset( new SvtLoadOptions_Impl);
 
         ItemHolder1::holdConfigItem(EItem::SaveOptions);
    }
    ++nRefCount;
-    pImp = pOptions;
+    pImp = pOptions.get();
 }
 
 SvtSaveOptions::~SvtSaveOptions()
@@ -823,9 +823,7 @@ SvtSaveOptions::~SvtSaveOptions()
         if ( pOptions->pLoadOpt->IsModified() )
             pOptions->pLoadOpt->Commit();
 
-        DELETEZ( pOptions->pLoadOpt );
-        DELETEZ( pOptions->pSaveOpt );
-        DELETEZ( pOptions );
+        pOptions.reset();
     }
 }
 


More information about the Libreoffice-commits mailing list