sw/source/core/layout/flycnt.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
New commits: commit 724c17602fac7476f068e6b66f30e9ef3c9f0940 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jun 7 14:16:23 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jun 7 18:04:19 2024 +0200 tdf#161215 sw: layout: don't move into section frame on same page The problem is that in SwFrame::GetNextFlyLeaf() pLayLeaf is in the body on the same page as pFlyAnchor, so the MoveSubTree() effectively removes the pNext chain from the layout into a circular structure whose upper is an indirect lower, causing an infinite loop later. Change-Id: I08f96cf483205d6213d7cec7b239f750fff5d3ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168529 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 89cd2e0bb876..03d95c979f11 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1629,7 +1629,17 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) { // Make sure the candidate is not inside the same body frame, that would prevent // inserting a new page. - if (pFlyAnchor->FindBodyFrame() == pLayLeaf->FindBodyFrame()) + SwBodyFrame const* pAnchorBody(pFlyAnchor->FindBodyFrame()); + while (!pAnchorBody->IsPageBodyFrame()) + { + pAnchorBody = pAnchorBody->GetUpper()->FindBodyFrame(); + }; + SwBodyFrame const* pLeafBody(pLayLeaf->FindBodyFrame()); + while (!pLeafBody->IsPageBodyFrame()) + { + pLeafBody = pLeafBody->GetUpper()->FindBodyFrame(); + }; + if (pAnchorBody == pLeafBody) { bSameBody = true; } commit e607bf096d4fb182388ccaefb1179cdd924af02a Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Jun 7 13:59:04 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jun 7 18:04:13 2024 +0200 tdf#161217 sw: layout: don't move into to-be-deleted section frame The problem is that in SwFrame::GetNextFlyLeaf() pLayLeaf is found inside a SwSectionFrame that has no m_pSection because it has been scheduled for deletion via SwRootFrame::InsertEmptySct(). Skip such frames, now it goes into infinite loop later... Change-Id: I93e5febba19213c1503fd699c8e4517067c6ec6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168528 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 1913ef6c0f81..89cd2e0bb876 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1651,7 +1651,13 @@ SwLayoutFrame *SwFrame::GetNextFlyLeaf( MakePageType eMakePage ) { // The above conditions are not held, reject. pOldLayLeaf = pLayLeaf; - pLayLeaf = pLayLeaf->GetNextLayoutLeaf(); + do + { + pLayLeaf = pLayLeaf->GetNextLayoutLeaf(); + } + // skip deleted section frames - do not move into these + while (pLayLeaf && pLayLeaf->FindSctFrame() + && !pLayLeaf->FindSctFrame()->GetSection()); if (pLayLeaf && pLayLeaf->IsInDocBody() && !bSameBody && !pLayLeaf->IsInFly() && pLayLeaf->IsInTab()) {