sw/source/core/layout/frmtool.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 98bcf50ad1e1e584d2f070693d10bf5084146eb2
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Oct 6 19:22:51 2022 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Oct 7 13:19:55 2022 +0200

    tdf#150500 sw_fieldmarkhide: fix duplicate text frame on paste
    
    The problem is that in MakeFrames() after the 1st iteration the
    SwNode2Layout::NextFrame() on node 10 returns a SwTextFrame that was
    just created by the 1st iteration, due to a fieldmark merging the 2
    SwTextNodes.
    
    Only itreate the frames that are pre-existing.
    
    (regression from commit 2f726fa41cbd249f2fb30222b29d5f30bce52e6e)
    
    Change-Id: Iba684dfc903e1c72ca3e70a9aabf1aecf4baf32b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141032
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index 4c535d18c9b8..93f02c5bf756 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2023,9 +2023,14 @@ void MakeFrames( SwDoc *pDoc, SwNode &rSttIdx, SwNode 
&rEndIdx )
     {
         bool bApres = *pNd < rSttIdx;
         SwNode2Layout aNode2Layout( *pNd, rSttIdx.GetIndex() );
-        SwFrame* pFrame;
         sw::FrameMode eMode = sw::FrameMode::Existing;
-        while( nullptr != (pFrame = aNode2Layout.NextFrame()) )
+        ::std::vector<SwFrame*> frames;
+        while (SwFrame* pFrame = aNode2Layout.NextFrame())
+        {   // tdf#150500 new frames may be created that end up merged on pNd
+            // so copy the currently existing ones; they shouldn't get deleted
+            frames.push_back(pFrame);
+        }
+        for (SwFrame *const pFrame : frames)
         {
             SwLayoutFrame *pUpper = pFrame->GetUpper();
             SwFootnoteFrame* pFootnoteFrame = pUpper->FindFootnoteFrame();

Reply via email to