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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 20 09:16:58 UTC 2018


 sd/source/ui/animations/CustomAnimationDialog.cxx |   31 +++++++++-------------
 sd/source/ui/animations/CustomAnimationDialog.hxx |    8 ++---
 sd/source/ui/animations/CustomAnimationPane.cxx   |    5 ++-
 3 files changed, 21 insertions(+), 23 deletions(-)

New commits:
commit cebcb879c169171f9c1306999e3843d081f4c2ce
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jun 11 16:05:21 2018 +0200

    loplugin:useuniqueptr in PropertyControl
    
    Change-Id: I6b648f26f3946da27585a70f18406e92d9de80c2
    Reviewed-on: https://gerrit.libreoffice.org/56107
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index 95f23249006f..224bf1223bc1 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -2285,18 +2285,15 @@ PropertyControl::~PropertyControl()
 
 void PropertyControl::dispose()
 {
-    delete mpSubControl;
+    mpSubControl.reset();
     ListBox::dispose();
 }
 
-void PropertyControl::setSubControl( PropertySubControl* pSubControl )
+void PropertyControl::setSubControl( std::unique_ptr<PropertySubControl> pSubControl )
 {
-    if( mpSubControl && mpSubControl != pSubControl )
-        delete mpSubControl;
+    mpSubControl = std::move(pSubControl);
 
-    mpSubControl = pSubControl;
-
-    Control* pControl = pSubControl ? pSubControl->getControl() : nullptr;
+    Control* pControl = mpSubControl ? mpSubControl->getControl() : nullptr;
 
     if( pControl )
     {
@@ -2323,15 +2320,15 @@ PropertySubControl::~PropertySubControl()
 {
 }
 
-PropertySubControl* PropertySubControl::create( sal_Int32 nType, vcl::Window* pParent, const Any& rValue, const OUString& rPresetId, const Link<LinkParamNone*,void>& rModifyHdl )
+std::unique_ptr<PropertySubControl> PropertySubControl::create( sal_Int32 nType, vcl::Window* pParent, const Any& rValue, const OUString& rPresetId, const Link<LinkParamNone*,void>& rModifyHdl )
 {
-    PropertySubControl* pSubControl = nullptr;
+    std::unique_ptr<PropertySubControl> pSubControl;
     switch( nType )
     {
     case nPropertyTypeDirection:
     case nPropertyTypeSpokes:
     case nPropertyTypeZoom:
-        pSubControl = new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl );
+        pSubControl.reset( new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl ) );
         break;
 
     case nPropertyTypeColor:
@@ -2339,31 +2336,31 @@ PropertySubControl* PropertySubControl::create( sal_Int32 nType, vcl::Window* pP
     case nPropertyTypeFirstColor:
     case nPropertyTypeCharColor:
     case nPropertyTypeLineColor:
-        pSubControl = new ColorPropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new ColorPropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeFont:
-        pSubControl = new FontPropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new FontPropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeCharHeight:
-        pSubControl = new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeRotate:
-        pSubControl = new RotationPropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new RotationPropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeTransparency:
-        pSubControl = new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeScale:
-        pSubControl = new ScalePropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new ScalePropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
 
     case nPropertyTypeCharDecoration:
-        pSubControl = new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl );
+        pSubControl.reset( new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl ) );
         break;
     }
 
diff --git a/sd/source/ui/animations/CustomAnimationDialog.hxx b/sd/source/ui/animations/CustomAnimationDialog.hxx
index 4d0c685dabb1..2ad30fb2bcb1 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.hxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.hxx
@@ -105,7 +105,7 @@ public:
 
     virtual Control*    getControl() = 0;
 
-    static PropertySubControl*
+    static std::unique_ptr<PropertySubControl>
                         create( sal_Int32 nType,
                                 vcl::Window* pParent,
                                 const css::uno::Any& rValue,
@@ -125,13 +125,13 @@ public:
     virtual ~PropertyControl() override;
     virtual void dispose() override;
 
-    void setSubControl( PropertySubControl* pSubControl );
-    PropertySubControl* getSubControl() const { return mpSubControl; }
+    void setSubControl( std::unique_ptr<PropertySubControl> pSubControl );
+    PropertySubControl* getSubControl() const { return mpSubControl.get(); }
 
     virtual void Resize() override;
 
 private:
-    PropertySubControl* mpSubControl;
+    std::unique_ptr<PropertySubControl> mpSubControl;
 };
 
 class CustomAnimationDurationTabPage;
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index cca48273915f..4f57fe860884 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -590,8 +590,9 @@ void CustomAnimationPane::updateControls()
                 pSubControl = mpLBProperty->getSubControl();
                 if( !pSubControl || (pSubControl->getControlType() != mnPropertyType) )
                 {
-                    pSubControl = PropertySubControl::create( mnPropertyType, mpPlaceholderBox, aValue, pEffect->getPresetId(), LINK( this, CustomAnimationPane, implPropertyHdl ) );
-                    mpLBProperty->setSubControl( pSubControl );
+                    auto pNewControl = PropertySubControl::create( mnPropertyType, mpPlaceholderBox, aValue, pEffect->getPresetId(), LINK( this, CustomAnimationPane, implPropertyHdl ) );
+                    pSubControl = pNewControl.get();
+                    mpLBProperty->setSubControl( std::move(pNewControl) );
                 }
                 else
                 {


More information about the Libreoffice-commits mailing list