diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-26 15:41:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-27 08:36:04 +0200 |
commit | db28098265cb1f137813c2f6c42663382c213aa5 (patch) | |
tree | 9dab7d3f2525ba4d9f7d16af178e99d6be79224b | |
parent | 0541b41705946a8086f3ad2c5366765c389e5480 (diff) |
loplugin:useuniqueptr in DocumentDrawModelManager
Change-Id: Id7a50d5379f8d2f8ecd39a75a520b1501600adcb
Reviewed-on: https://gerrit.libreoffice.org/56501
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/doc/DocumentDrawModelManager.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentDrawModelManager.hxx | 4 |
2 files changed, 8 insertions, 11 deletions
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 |