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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 6 10:41:32 UTC 2018


 include/vcl/lazydelete.hxx                       |    8 ++++----
 sd/source/ui/view/viewoverlaymanager.cxx         |    5 +++--
 svx/source/sdr/primitive2d/sdrprimitivetools.cxx |    3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 2855fa6eef83ec670d927b46dc7f987c66d93057
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 3 15:55:58 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 6 12:40:33 2018 +0200

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

diff --git a/include/vcl/lazydelete.hxx b/include/vcl/lazydelete.hxx
index 403b54abc193..89c88cbf4cc2 100644
--- a/include/vcl/lazydelete.hxx
+++ b/include/vcl/lazydelete.hxx
@@ -224,17 +224,17 @@ namespace vcl
     template < typename T >
     class DeleteOnDeinit : public DeleteOnDeinitBase
     {
-        T* m_pT;
-        virtual void doCleanup() override { delete m_pT; m_pT = nullptr; }
+        std::unique_ptr<T> m_pT;
+        virtual void doCleanup() override { m_pT.reset(); }
     public:
         DeleteOnDeinit( T* i_pT ) : m_pT( i_pT ) { addDeinitContainer( this ); }
 
         // get contents
-        T* get() { return m_pT; }
+        T* get() { return m_pT.get(); }
 
         // set contents, returning old contents
         // ownership is transferred !
-        T* set( T* i_pNew ) { T* pOld = m_pT; m_pT = i_pNew; return pOld; }
+        std::unique_ptr<T> set( std::unique_ptr<T> i_pNew ) { auto pOld = std::move(m_pT); m_pT = std::move(i_pNew); return pOld; }
     };
 
     /** Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx
index 215a3a0038e7..c65380d83d7d 100644
--- a/sd/source/ui/view/viewoverlaymanager.cxx
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -19,6 +19,7 @@
 
 #include <sddll.hxx>
 
+#include <o3tl/make_unique.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/app.hxx>
@@ -94,8 +95,8 @@ static BitmapEx* getButtonImage( int index, bool large )
     {
         for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aSmallPlaceHolders); i++ )
         {
-            gSmallButtonImages[i].set(new BitmapEx(aSmallPlaceHolders[i]));
-            gLargeButtonImages[i].set(new BitmapEx(aBigPlaceHolders[i]));
+            gSmallButtonImages[i].set(o3tl::make_unique<BitmapEx>(aSmallPlaceHolders[i]));
+            gLargeButtonImages[i].set(o3tl::make_unique<BitmapEx>(aBigPlaceHolders[i]));
         }
     }
 
diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
index 8eecbeee0715..e46c426191af 100644
--- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
+++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
@@ -19,6 +19,7 @@
 
 #include <sdr/primitive2d/sdrprimitivetools.hxx>
 #include <osl/mutex.hxx>
+#include <o3tl/make_unique.hxx>
 #include <vcl/lazydelete.hxx>
 #include <vcl/BitmapTools.hxx>
 
@@ -56,7 +57,7 @@ namespace drawinglayer
                 BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, 32);
 
                 // create and exchange at aRetVal
-                delete aRetVal.set(new BitmapEx(aBitmap));
+                aRetVal.set(o3tl::make_unique<BitmapEx>(aBitmap));
             }
 
             return aRetVal.get() ? *aRetVal.get() : BitmapEx();


More information about the Libreoffice-commits mailing list