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

Noel Grandin noel.grandin at collabora.co.uk
Wed May 2 06:27:40 UTC 2018


 include/svx/galmisc.hxx         |    7 ++++---
 svx/source/gallery2/galmisc.cxx |   15 ++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)

New commits:
commit b6025e6cffe2024fefebd161ea739188b4b4fdaf
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue May 1 18:00:37 2018 +0200

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

diff --git a/include/svx/galmisc.hxx b/include/svx/galmisc.hxx
index fbc3a4bc9a98..d48f144ec514 100644
--- a/include/svx/galmisc.hxx
+++ b/include/svx/galmisc.hxx
@@ -31,6 +31,7 @@
 #include <svx/svxdllapi.h>
 #include <tools/date.hxx>
 #include <tools/time.hxx>
+#include <memory>
 
 class GalleryTheme;
 class SotStorageStream;
@@ -142,9 +143,9 @@ using TransferableHelper::CopyToClipboard;
     GalleryTheme*                   mpTheme;
     SgaObjKind                      meObjectKind;
     sal_uInt32                      mnObjectPos;
-    tools::SvRef<SotStorageStream>             mxModelStream;
-    GraphicObject*                  mpGraphicObject;
-    INetURLObject*                  mpURL;
+    tools::SvRef<SotStorageStream>  mxModelStream;
+    std::unique_ptr<GraphicObject>  mpGraphicObject;
+    std::unique_ptr<INetURLObject>  mpURL;
 
                                     GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
                                     virtual ~GalleryTransferable() override;
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index 5cc0006b9c7e..94abe00ce6b5 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -403,7 +403,7 @@ void GalleryTransferable::InitData( bool bLazy )
                     Graphic aGraphic;
 
                     if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
-                        mpGraphicObject = new GraphicObject( aGraphic );
+                        mpGraphicObject.reset(new GraphicObject( aGraphic ));
                 }
 
                 if( !mxModelStream.is() )
@@ -427,12 +427,11 @@ void GalleryTransferable::InitData( bool bLazy )
         {
             if( !mpURL )
             {
-                mpURL = new INetURLObject;
+                mpURL.reset(new INetURLObject);
 
                 if( !mpTheme->GetURL( mnObjectPos, *mpURL ) )
                 {
-                    delete mpURL;
-                    mpURL = nullptr;
+                    mpURL.reset();
                 }
             }
 
@@ -441,7 +440,7 @@ void GalleryTransferable::InitData( bool bLazy )
                 Graphic aGraphic;
 
                 if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
-                    mpGraphicObject = new GraphicObject( aGraphic );
+                    mpGraphicObject.reset(new GraphicObject( aGraphic ));
             }
         }
         break;
@@ -544,10 +543,8 @@ void GalleryTransferable::DragFinished( sal_Int8 nDropAction )
 void GalleryTransferable::ObjectReleased()
 {
     mxModelStream.clear();
-    delete mpGraphicObject;
-    mpGraphicObject = nullptr;
-    delete mpURL;
-    mpURL = nullptr;
+    mpGraphicObject.reset();
+    mpURL.reset();
 }
 
 void GalleryTransferable::StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions )


More information about the Libreoffice-commits mailing list