sw/source/uibase/inc/wrtsh.hxx | 10 +++++----- sw/source/uibase/wrtsh/move.cxx | 14 ++++---------- sw/source/uibase/wrtsh/select.cxx | 4 +--- 3 files changed, 10 insertions(+), 18 deletions(-)
New commits: commit fb90f975cb5f744f8dbe64b9a1514d4d7ace746d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jul 25 13:44:52 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Jul 26 08:34:27 2018 +0200 loplugin:useuniqueptr in SwWrtShell Change-Id: I570b45e4174375be9e30f6ebc8c8171cace78990 Reviewed-on: https://gerrit.libreoffice.org/58015 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index 6fbbb38d3d7e..797bd3e525da 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -511,23 +511,23 @@ private: struct CursorStack { Point aDocPos; - CursorStack *pNext; + std::unique_ptr<CursorStack> pNext; bool bValidCurPos : 1; bool bIsFrameSel : 1; SwTwips lOffset; CursorStack( bool bValid, bool bFrameSel, const Point &rDocPos, - SwTwips lOff, CursorStack *pN ) + SwTwips lOff, std::unique_ptr<CursorStack> pN ) : aDocPos(rDocPos), - pNext(pN), + pNext(std::move(pN)), bValidCurPos( bValid ), bIsFrameSel( bFrameSel ), lOffset(lOff) { - } - } *m_pCursorStack; + }; + std::unique_ptr<CursorStack> m_pCursorStack; SwView &m_rView; SwNavigationMgr m_aNavigationMgr; diff --git a/sw/source/uibase/wrtsh/move.cxx b/sw/source/uibase/wrtsh/move.cxx index a848e1d18dc2..afcdd9d7f58e 100644 --- a/sw/source/uibase/wrtsh/move.cxx +++ b/sw/source/uibase/wrtsh/move.cxx @@ -467,8 +467,8 @@ bool SwWrtShell::PushCursor(SwTwips lOffset, bool bSelect) // Position into the stack; bDiff indicates if there is a // difference between the old and the new cursor position. - m_pCursorStack = new CursorStack( bDiff, bIsFrameSel, aOldRect.Center(), - lOffset, m_pCursorStack ); + m_pCursorStack.reset( new CursorStack( bDiff, bIsFrameSel, aOldRect.Center(), + lOffset, std::move(m_pCursorStack) ) ); return !m_bDestOnStack && bDiff; } @@ -508,9 +508,7 @@ bool SwWrtShell::PopCursor(bool bUpdate, bool bSelect) return false; } } - CursorStack *pTmp = m_pCursorStack; - m_pCursorStack = m_pCursorStack->pNext; - delete pTmp; + m_pCursorStack = std::move(m_pCursorStack->pNext); if( nullptr == m_pCursorStack ) { m_ePageMove = MV_NO; @@ -525,11 +523,7 @@ bool SwWrtShell::PopCursor(bool bUpdate, bool bSelect) void SwWrtShell::ResetCursorStack_() { while(m_pCursorStack) - { - CursorStack* const pTmp = m_pCursorStack->pNext; - delete m_pCursorStack; - m_pCursorStack = pTmp; - } + m_pCursorStack = std::move(m_pCursorStack->pNext); m_ePageMove = MV_NO; m_bDestOnStack = false; } diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx index 839a95572d2f..f12005e5cbab 100644 --- a/sw/source/uibase/wrtsh/select.cxx +++ b/sw/source/uibase/wrtsh/select.cxx @@ -294,9 +294,7 @@ void SwWrtShell::PopMode() LeaveBlockMode(); m_bIns = m_pModeStack->bIns; - ModeStack *pTmp = m_pModeStack->pNext; - delete m_pModeStack; - m_pModeStack = pTmp; + m_pModeStack = std::move(m_pModeStack->pNext); } // Two methods for setting cursors: the first maps at the _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits