[Libreoffice-commits] core.git: sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Nov 3 08:55:49 UTC 2020
sw/source/core/layout/objectformattertxtfrm.cxx | 40 +++++++++++++++---------
1 file changed, 25 insertions(+), 15 deletions(-)
New commits:
commit 3726c6e22d5cc9934f17cb73b3b5b5144eca2452
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Nov 2 14:54:36 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Nov 3 09:55:05 2020 +0100
extract cleanup piece to its own function
this is from a failed campaign against tdf#122894
Change-Id: I639d65394cadca6ca70613dfd13691fd7b5f5104
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105191
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx
index 3836c138f79d..2109835ba841 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -665,6 +665,30 @@ bool SwObjectFormatterTextFrame::CheckMovedFwdCondition(
return bAnchorIsMovedForward;
}
+static void CleanupEmptyFootnoteFrame(SwFrame* pLowerFrame)
+{
+ // Calc on a SwTextFrame in a footnote can move it to the next page -
+ // deletion of the SwFootnoteFrame was disabled with SwFrameDeleteGuard
+ // but now we have to clean up empty footnote frames to prevent crashes.
+ // Note: check it at this level, not lower: both container and footnote
+ // can be deleted at the same time!
+ if (pLowerFrame->IsFootnoteContFrame())
+ {
+ for (SwFrame * pFootnote = pLowerFrame->GetLower(); pFootnote; )
+ {
+ assert(pFootnote->IsFootnoteFrame());
+ SwFrame *const pNextNote = pFootnote->GetNext();
+ if (!pFootnote->IsDeleteForbidden() && !pFootnote->GetLower() && !pFootnote->IsColLocked() &&
+ !static_cast<SwFootnoteFrame*>(pFootnote)->IsBackMoveLocked())
+ {
+ pFootnote->Cut();
+ SwFrame::DestroyFrame(pFootnote);
+ }
+ pFootnote = pNextNote;
+ }
+ }
+}
+
// #i40140# - helper method to format layout frames used by
// method <SwObjectFormatterTextFrame::FormatAnchorFrameForCheckMoveFwd()>
// #i44049# - format till a certain lower frame, if provided.
@@ -694,21 +718,7 @@ static void lcl_FormatContentOfLayoutFrame( SwLayoutFrame* pLayFrame,
// Note: check it at this level, not lower: both container and footnote
// can be deleted at the same time!
SwFrame *const pNext = pLowerFrame->GetNext();
- if (pLowerFrame->IsFootnoteContFrame())
- {
- for (SwFrame * pFootnote = pLowerFrame->GetLower(); pFootnote; )
- {
- assert(pFootnote->IsFootnoteFrame());
- SwFrame *const pNextNote = pFootnote->GetNext();
- if (!pFootnote->IsDeleteForbidden() && !pFootnote->GetLower() && !pFootnote->IsColLocked() &&
- !static_cast<SwFootnoteFrame*>(pFootnote)->IsBackMoveLocked())
- {
- pFootnote->Cut();
- SwFrame::DestroyFrame(pFootnote);
- }
- pFootnote = pNextNote;
- }
- }
+ CleanupEmptyFootnoteFrame(pLowerFrame);
pLowerFrame = pNext;
}
}
More information about the Libreoffice-commits
mailing list