From 9abbe6746cb4d36e3ccb384f96ccafb9e0612cd6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 12 Sep 2018 10:26:24 +0200 Subject: [PATCH] loplugin:useuniqueptr in lcl_UpdateLinksInSect Change-Id: Id9e8f142b8cc4b2a4418b3cde59e98bb7f045fe6 Reviewed-on: https://gerrit.libreoffice.org/60410 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/docnode/section.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 8eecfc5ac4c7..5c6170ad5869 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1192,7 +1192,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) bool bWasVisibleLinks = pDoc->getIDocumentLinksAdministration().IsVisibleLinks(); pDoc->getIDocumentLinksAdministration().SetVisibleLinks( false ); - SwPaM* pPam; + std::unique_ptr pPam; SwViewShell* pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); SwEditShell* pESh = pDoc->GetEditShell(); pDoc->getIDocumentFieldsAccess().LockExpFields(); @@ -1212,7 +1212,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) --aPos.nNode; SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true ); - pPam = new SwPaM( aPos ); + pPam.reset(new SwPaM( aPos )); // Delete everything succeeding it --aIdx; @@ -1396,8 +1396,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) pESh->Push(); SwPaM* pCursor = pESh->GetCursor(); *pCursor->GetPoint() = *pPam->GetPoint(); - delete pPam; - pPam = pCursor; + pPam.reset(pCursor); } SvMemoryStream aStrm( const_cast(aSeq.getConstArray()), aSeq.getLength(), @@ -1432,7 +1431,6 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) pESh->EndAllAction(); else if( pVSh ) pVSh->EndAction(); - delete pPam; // Was created at the start return SUCCESS; }