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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 27 06:36:28 UTC 2018


 sw/source/core/doc/DocumentDrawModelManager.cxx |   15 ++++++---------
 sw/source/core/inc/DocumentDrawModelManager.hxx |    4 ++--
 2 files changed, 8 insertions(+), 11 deletions(-)

New commits:
commit db28098265cb1f137813c2f6c42663382c213aa5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jun 26 15:41:21 2018 +0200

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

diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx
index 7ce5c2543465..f0b9a42e57d7 100644
--- a/sw/source/core/doc/DocumentDrawModelManager.cxx
+++ b/sw/source/core/doc/DocumentDrawModelManager.cxx
@@ -79,7 +79,7 @@ void DocumentDrawModelManager::InitDrawModel()
 
     SAL_INFO( "sw.doc", "before create DrawDocument" );
     // The document owns the SwDrawModel. We always have two layers and one page.
-    mpDrawModel = new SwDrawModel( &m_rDoc );
+    mpDrawModel.reset( new SwDrawModel( &m_rDoc ) );
 
     mpDrawModel->EnableUndo( m_rDoc.GetIDocumentUndoRedo().DoesUndo() );
 
@@ -154,22 +154,19 @@ void DocumentDrawModelManager::InitDrawModel()
 
 void DocumentDrawModelManager::ReleaseDrawModel()
 {
-    if ( mpDrawModel )
-    {
-        // !! Also maintain the code in the sw3io for inserting documents!!
-        delete mpDrawModel; mpDrawModel = nullptr;
-    }
+    // !! Also maintain the code in the sw3io for inserting documents!!
+    mpDrawModel.reset();
 }
 
 
 const SwDrawModel* DocumentDrawModelManager::GetDrawModel() const
 {
-    return mpDrawModel;
+    return mpDrawModel.get();
 }
 
 SwDrawModel* DocumentDrawModelManager::GetDrawModel()
 {
-    return mpDrawModel;
+    return mpDrawModel.get();
 }
 
 SwDrawModel* DocumentDrawModelManager::MakeDrawModel_()
@@ -189,7 +186,7 @@ SwDrawModel* DocumentDrawModelManager::MakeDrawModel_()
             m_rDoc.GetDocShell()->Broadcast( aHint );
         }
     }
-    return mpDrawModel;
+    return mpDrawModel.get();
 }
 
 SwDrawModel* DocumentDrawModelManager::GetOrCreateDrawModel()
diff --git a/sw/source/core/inc/DocumentDrawModelManager.hxx b/sw/source/core/inc/DocumentDrawModelManager.hxx
index ace32172a538..ec78263112e6 100644
--- a/sw/source/core/inc/DocumentDrawModelManager.hxx
+++ b/sw/source/core/inc/DocumentDrawModelManager.hxx
@@ -23,6 +23,7 @@
 #include <sal/types.h>
 #include <IDocumentDrawModelAccess.hxx>
 #include <svx/svdtypes.hxx>
+#include <memory>
 
 class SwDrawModel;
 class SdrPageView;
@@ -68,8 +69,7 @@ private:
 
     SwDoc& m_rDoc;
 
-
-    SwDrawModel* mpDrawModel;
+    std::unique_ptr<SwDrawModel> mpDrawModel;
 
     /** Draw Model Layer IDs
      * LayerIds, Heaven == above document


More information about the Libreoffice-commits mailing list