From ca41437a880a3c40d22557ed3a29203b06eec993 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 20 May 2022 16:01:57 +0200 Subject: sw: avoid ~SwIndexReg() assert in SwFEShell::PastePages() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5337dc8568255a778d29b676a39c99f72c42486b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134693 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 1b8c42f8b007d690a85676f260b28b44639fc79a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134777 Tested-by: Thorsten Behrens Reviewed-by: Thorsten Behrens Reviewed-by: Caolán McNamara --- sw/source/core/frmedt/fecopy.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index b7a12a828b90..a907e0e838a0 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -1133,7 +1133,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1 return; } MovePage( GetThisFrame, GetFirstSub ); - SwPaM aCpyPam( *GetCursor()->GetPoint() ); + ::std::optional oSourcePam( *GetCursor()->GetPoint() ); OUString sStartingPageDesc = GetPageDesc( GetCurPageDesc()).GetName(); SwPageDesc* pDesc = rToFill.FindPageDescByName( sStartingPageDesc, true ); if( pDesc ) @@ -1145,7 +1145,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1 return; } //if the page starts with a table a paragraph has to be inserted before - SwNode* pTableNode = aCpyPam.GetNode().FindTableNode(); + SwNode *const pTableNode = oSourcePam->GetNode().FindTableNode(); if(pTableNode) { //insert a paragraph @@ -1155,22 +1155,23 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1 if(GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore )) { SwPaM aTmp(aBefore); - aCpyPam = aTmp; + *oSourcePam = aTmp; } EndUndo(SwUndoId::INSERT); } MovePage( GetThisFrame, GetLastSub ); - aCpyPam.SetMark(); - *aCpyPam.GetMark() = *GetCursor()->GetPoint(); + oSourcePam->SetMark(); + *oSourcePam->GetMark() = *GetCursor()->GetPoint(); CurrShell aCurr( this ); StartAllAction(); GetDoc()->getIDocumentFieldsAccess().LockExpFields(); - SetSelection(aCpyPam); + SetSelection(*oSourcePam); // copy the text of the selection SwEditShell::Copy(rToFill); + oSourcePam.reset(); // delete it because Undo will remove its node! if(pTableNode) { -- cgit