tdf#151866 sw: layout: prevent deleting newly created SwSectionFrame
A section frame is created so that content can move back from another
page into it.
Apparently only the pPrv frame is on the same page, and formatting it in
SwFrame::MakePos() moves it backward, then CheckPageDescs() sees a page
with only empty section frames on it and deletes the whole page.
(regression from commit b9ef71476fd70bc13f50ebe80390e0730d1b7afb)
Change-Id: I4f8e4debd4bcf993c9355dcfc3ced779fe6732ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155467
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 73a4ced..820d783 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -542,6 +542,9 @@ void SwFrame::MakePos()
!pPrv->GetAttrSet()->GetKeep().GetValue()
)
{
// tdf#151866 pPrv may MoveBwd and if this is a newly created
// section frame then CheckPageDescs() may delete the whole page!
SwFrameDeleteGuard g(this); // Prevent it.
pPrv->Calc(getRootFrame()->GetCurrShell() ? getRootFrame()->GetCurrShell()->GetOut() : nullptr); // This may cause Prev to vanish!
}
else if ( pPrv->getFrameArea().Top() == 0 )