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

New commits:
commit 0fb5f7e22b68fc045843af95ca3918c1d92a8656
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Oct 6 19:22:51 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Oct 7 20:27:39 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>
    (cherry picked from commit 21358e0502995238b85677d72a005f3f96d60f7f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141059
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index ee50dcc7cd12..ecd69e9012ab 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2026,9 +2026,14 @@ void MakeFrames( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
     {
         bool bApres = aTmp < 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