diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-28 13:57:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-29 08:41:30 +0200 |
commit | 95486bac7090d163d19fe8d35521ac0ef4473a93 (patch) | |
tree | b0ff2c300046becb381f533e22c637746422cea7 /sw | |
parent | 35c165e46a1bc22bc4c5b51ec7b03216fa43ec64 (diff) |
loplugin:useuniqueptr in SwEnterLeave
Change-Id: I948c146f675675c1902c158be4d97b6d19679a51
Reviewed-on: https://gerrit.libreoffice.org/56625
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/dbg_lay.hxx | 20 | ||||
-rw-r--r-- | sw/source/core/layout/dbg_lay.cxx | 25 |
2 files changed, 15 insertions, 30 deletions
diff --git a/sw/source/core/inc/dbg_lay.hxx b/sw/source/core/inc/dbg_lay.hxx index 95e491782ff6..5c46809f88ae 100644 --- a/sw/source/core/inc/dbg_lay.hxx +++ b/sw/source/core/inc/dbg_lay.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_DBG_LAY_HXX #include <o3tl/typed_flags_set.hxx> +#include <memory> enum class PROT { FileInit = 0x00000000, @@ -84,23 +85,10 @@ public: class SwEnterLeave { - SwImplEnterLeave* pImpl; - void Ctor( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ); - void Dtor(); - + std::unique_ptr<SwImplEnterLeave> pImpl; public: - SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) - { - if( SwProtocol::Record( nFunc ) ) - Ctor( pFrame, nFunc, nAct, pPar ); - else - pImpl = nullptr; - } - ~SwEnterLeave() - { - if( pImpl ) - Dtor(); - } + SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ); + ~SwEnterLeave(); }; #define PROTOCOL( pFrame, nFunc, nAct, pPar ) { if( SwProtocol::Record( nFunc ) )\ diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx index 203f07893296..8db7a0d79a22 100644 --- a/sw/source/core/layout/dbg_lay.cxx +++ b/sw/source/core/layout/dbg_lay.cxx @@ -860,37 +860,34 @@ void SwImplProtocol::DeleteFrame( sal_uInt16 nId ) pFrameIds->erase(nId); } -/* SwEnterLeave::Ctor(..) is called from the (inline-)CTor if the function should - * be logged. +/* * The task here is to find the right SwImplEnterLeave object based on the * function; everything else is then done in his Ctor/Dtor. */ -void SwEnterLeave::Ctor( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) +SwEnterLeave::SwEnterLeave( const SwFrame* pFrame, PROT nFunc, DbgAction nAct, void* pPar ) { + if( !SwProtocol::Record( nFunc ) ) + return; switch( nFunc ) { case PROT::AdjustN : case PROT::Grow: - case PROT::Shrink : pImpl = new SwSizeEnterLeave( pFrame, nFunc, nAct, pPar ); break; + case PROT::Shrink : pImpl.reset( new SwSizeEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; case PROT::MoveFwd: - case PROT::MoveBack : pImpl = new SwUpperEnterLeave( pFrame, nFunc, nAct, pPar ); break; - case PROT::FrmChanges : pImpl = new SwFrameChangesLeave( pFrame, nFunc, nAct, pPar ); break; - default: pImpl = new SwImplEnterLeave( pFrame, nFunc, nAct, pPar ); break; + case PROT::MoveBack : pImpl.reset( new SwUpperEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; + case PROT::FrmChanges : pImpl.reset( new SwFrameChangesLeave( pFrame, nFunc, nAct, pPar ) ); break; + default: pImpl.reset( new SwImplEnterLeave( pFrame, nFunc, nAct, pPar ) ); break; } pImpl->Enter(); } -/* SwEnterLeave::Dtor() only calls the Dtor of the SwImplEnterLeave object. It's - * just no inline because we don't want the SwImplEnterLeave definition inside +/* This is not inline because we don't want the SwImplEnterLeave definition inside * dbg_lay.hxx. */ -void SwEnterLeave::Dtor() +SwEnterLeave::~SwEnterLeave() { - if( pImpl ) - { + if (pImpl) pImpl->Leave(); - delete pImpl; - } } void SwImplEnterLeave::Enter() |