sw/source/core/layout/anchoreddrawobject.cxx | 25 +++++-------------------- sw/source/core/layout/flycnt.cxx | 21 ++++++--------------- sw/source/filter/basflt/shellio.cxx | 6 +++--- 3 files changed, 14 insertions(+), 38 deletions(-)
New commits: commit ec2cc68a666b573e226fce94919041538345cd9b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 26 15:27:01 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Sep 27 08:36:31 2018 +0200 loplugin:useuniqueptr in SwReader::Read Change-Id: Iff7936e440951e65653ef42ce5a2aebd22a03029 Reviewed-on: https://gerrit.libreoffice.org/61004 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index ccfd9d69c74e..c4bd839976fa 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -150,12 +150,12 @@ ErrCode SwReader::Read( const Reader& rOptions ) mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore ); - SwPaM* pUndoPam = nullptr; + std::unique_ptr<SwPaM> pUndoPam; if( bDocUndo || pCursor ) { // set Pam to the previous node, so that it is not also moved const SwNodeIndex& rTmp = pPam->GetPoint()->nNode; - pUndoPam = new SwPaM( rTmp, rTmp, 0, -1 ); + pUndoPam.reset(new SwPaM( rTmp, rTmp, 0, -1 )); } // store for now all Fly's @@ -316,7 +316,7 @@ ErrCode SwReader::Read( const Reader& rOptions ) mxDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::Ignore ); } - delete pUndoPam; + pUndoPam.reset(); pPam = pPam->GetNext(); if( pPam == pEnd ) commit 07e5c4381ac405b4379767f9735152b8f0314faa Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 26 14:08:43 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Sep 27 08:36:19 2018 +0200 loplugin:useuniqueptr in SwObjPosOscillationControl Point is a small object, no need to store separately on the heap Change-Id: Id8fb1829b711831860ad1d7709fb4bf71ae8ff09 Reviewed-on: https://gerrit.libreoffice.org/61002 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index 0a4292638342..88f9969a422f 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -137,11 +137,10 @@ class SwObjPosOscillationControl private: const SwAnchoredDrawObject* mpAnchoredDrawObj; - std::vector<Point*> maObjPositions; + std::vector<Point> maObjPositions; public: explicit SwObjPosOscillationControl( const SwAnchoredDrawObject& _rAnchoredDrawObj ); - ~SwObjPosOscillationControl(); bool OscillationDetected(); }; @@ -152,17 +151,6 @@ SwObjPosOscillationControl::SwObjPosOscillationControl( { } -SwObjPosOscillationControl::~SwObjPosOscillationControl() -{ - while ( !maObjPositions.empty() ) - { - Point* pPos = maObjPositions.back(); - delete pPos; - - maObjPositions.pop_back(); - } -} - bool SwObjPosOscillationControl::OscillationDetected() { bool bOscillationDetected = false; @@ -174,22 +162,19 @@ bool SwObjPosOscillationControl::OscillationDetected() } else { - Point* pNewObjPos = new Point( mpAnchoredDrawObj->GetObjRect().Pos() ); - for ( std::vector<Point*>::iterator aObjPosIter = maObjPositions.begin(); - aObjPosIter != maObjPositions.end(); - ++aObjPosIter ) + Point aNewObjPos = mpAnchoredDrawObj->GetObjRect().Pos(); + for ( auto const & pt : maObjPositions ) { - if ( *pNewObjPos == *(*aObjPosIter) ) + if ( aNewObjPos == pt ) { // position already occurred -> oscillation bOscillationDetected = true; - delete pNewObjPos; break; } } if ( !bOscillationDetected ) { - maObjPositions.push_back( pNewObjPos ); + maObjPositions.push_back( aNewObjPos ); } } diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 5d9f1ba2fce5..0b0de1ed1076 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -210,7 +210,7 @@ class SwOszControl static const SwFlyFrame *pStack5; const SwFlyFrame *pFly; - std::vector<Point*> maObjPositions; + std::vector<Point> maObjPositions; public: explicit SwOszControl( const SwFlyFrame *pFrame ); @@ -253,13 +253,7 @@ SwOszControl::~SwOszControl() else if ( SwOszControl::pStack5 == pFly ) SwOszControl::pStack5 = nullptr; // #i3317# - while ( !maObjPositions.empty() ) - { - Point* pPos = maObjPositions.back(); - delete pPos; - - maObjPositions.pop_back(); - } + maObjPositions.clear(); } bool SwOszControl::IsInProgress( const SwFlyFrame *pFly ) @@ -288,22 +282,19 @@ bool SwOszControl::ChkOsz() } else { - Point* pNewObjPos = new Point( pFly->GetObjRect().Pos() ); - for ( std::vector<Point*>::iterator aObjPosIter = maObjPositions.begin(); - aObjPosIter != maObjPositions.end(); - ++aObjPosIter ) + Point aNewObjPos = pFly->GetObjRect().Pos(); + for ( auto const & pt : maObjPositions ) { - if ( *pNewObjPos == *(*aObjPosIter) ) + if ( aNewObjPos == pt ) { // position already occurred -> oscillation bOscillationDetected = true; - delete pNewObjPos; break; } } if ( !bOscillationDetected ) { - maObjPositions.push_back( pNewObjPos ); + maObjPositions.push_back( aNewObjPos ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits