[Libreoffice-commits] core.git: 2 commits - include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 5 06:56:27 UTC 2018


 include/svx/sdr/contact/viewobjectcontact.hxx |    3 ++-
 include/svx/sdrmasterpagedescriptor.hxx       |    3 ++-
 svx/source/sdr/contact/viewobjectcontact.cxx  |   14 +++-----------
 svx/source/svdraw/sdrmasterpagedescriptor.cxx |   10 +++-------
 4 files changed, 10 insertions(+), 20 deletions(-)

New commits:
commit 4573a50b477404b0d17c1c32c2ccb6b9503a0a0d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 30 11:27:56 2018 +0200

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

diff --git a/include/svx/sdr/contact/viewobjectcontact.hxx b/include/svx/sdr/contact/viewobjectcontact.hxx
index b5b1a35bda5e..ce17890ee93d 100644
--- a/include/svx/sdr/contact/viewobjectcontact.hxx
+++ b/include/svx/sdr/contact/viewobjectcontact.hxx
@@ -22,6 +22,7 @@
 
 #include <sal/types.h>
 
+#include <memory>
 #include <vector>
 #include <svx/svxdllapi.h>
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
@@ -55,7 +56,7 @@ private:
     drawinglayer::primitive2d::Primitive2DContainer  mxPrimitive2DSequence;
 
     // the PrimitiveAnimation if Primitive2DContainer contains animations
-    sdr::animation::PrimitiveAnimation*             mpPrimitiveAnimation;
+    std::unique_ptr<sdr::animation::PrimitiveAnimation> mpPrimitiveAnimation;
 
     // This bool gets set when the object gets invalidated by ActionChanged() and
     // can be used from the OC to late-invalidates
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx
index 324dc67bf091..e0d52153e525 100644
--- a/svx/source/sdr/contact/viewobjectcontact.cxx
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -178,11 +178,7 @@ ViewObjectContact::~ViewObjectContact()
     }
 
     // delete PrimitiveAnimation
-    if(mpPrimitiveAnimation)
-    {
-        delete mpPrimitiveAnimation;
-        mpPrimitiveAnimation = nullptr;
-    }
+    mpPrimitiveAnimation.reset();
 
     // take care of remembered ObjectContact. Remove from
     // OC first. The VC removal (below) CAN trigger a StopGettingViewed()
@@ -288,11 +284,7 @@ void ViewObjectContact::ActionChildInserted(ViewContact& rChild)
 void ViewObjectContact::checkForPrimitive2DAnimations()
 {
     // remove old one
-    if(mpPrimitiveAnimation)
-    {
-        delete mpPrimitiveAnimation;
-        mpPrimitiveAnimation = nullptr;
-    }
+    mpPrimitiveAnimation.reset();
 
     // check for animated primitives
     if(!mxPrimitive2DSequence.empty())
@@ -309,7 +301,7 @@ void ViewObjectContact::checkForPrimitive2DAnimations()
             if(!aAnimatedExtractor.getPrimitive2DSequence().empty())
             {
                 // derived primitiveList is animated, setup new PrimitiveAnimation
-                mpPrimitiveAnimation =  new sdr::animation::PrimitiveAnimation(*this, aAnimatedExtractor.getPrimitive2DSequence());
+                mpPrimitiveAnimation.reset( new sdr::animation::PrimitiveAnimation(*this, aAnimatedExtractor.getPrimitive2DSequence()) );
             }
         }
     }
commit 9b0ee7d25fd405153fa783cbc0b1658368a22355
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 30 10:50:58 2018 +0200

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

diff --git a/include/svx/sdrmasterpagedescriptor.hxx b/include/svx/sdrmasterpagedescriptor.hxx
index f719bca5322e..a072ed6ba5aa 100644
--- a/include/svx/sdrmasterpagedescriptor.hxx
+++ b/include/svx/sdrmasterpagedescriptor.hxx
@@ -22,6 +22,7 @@
 
 #include <svx/sdrpageuser.hxx>
 #include <svx/svdsob.hxx>
+#include <memory>
 
 class SdrObject;
 class SfxItemSet;
@@ -45,7 +46,7 @@ namespace sdr
         SdrLayerIDSet                                       maVisibleLayers;
 
         // ViewContact part
-        sdr::contact::ViewContact*                      mpViewContact;
+        mutable std::unique_ptr<sdr::contact::ViewContact>      mpViewContact;
 
         void operator=(const MasterPageDescriptor& rCandidate) = delete;
 
diff --git a/svx/source/svdraw/sdrmasterpagedescriptor.cxx b/svx/source/svdraw/sdrmasterpagedescriptor.cxx
index 3bc645fb4dc7..89f042c087e0 100644
--- a/svx/source/svdraw/sdrmasterpagedescriptor.cxx
+++ b/svx/source/svdraw/sdrmasterpagedescriptor.cxx
@@ -45,11 +45,7 @@ namespace sdr
         // de-register at used page
         maUsedPage.RemovePageUser(*this);
 
-        if(mpViewContact)
-        {
-            delete mpViewContact;
-            mpViewContact = nullptr;
-        }
+        mpViewContact.reset();
     }
 
     // ViewContact part
@@ -57,8 +53,8 @@ namespace sdr
     {
         if(!mpViewContact)
         {
-            const_cast< MasterPageDescriptor* >(this)->mpViewContact =
-                new sdr::contact::ViewContactOfMasterPageDescriptor(*const_cast< MasterPageDescriptor* >(this));
+            mpViewContact.reset(
+                new sdr::contact::ViewContactOfMasterPageDescriptor(*const_cast< MasterPageDescriptor* >(this)) );
         }
 
         return *mpViewContact;


More information about the Libreoffice-commits mailing list