sw/qa/extras/layout/layout.cxx | 3 --- sw/source/core/inc/objectformatter.hxx | 3 ++- sw/source/core/layout/fly.cxx | 6 ++++-- sw/source/core/layout/objectformatter.cxx | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-)
New commits: commit 191babee4f0ec643b80e96b0cd98c2d04ff96e4e Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Nov 16 19:45:05 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Nov 17 09:09:20 2023 +0100 sw: fix layout crash in SwObjectFormatterTextFrame::DoFormatObj() Since commit 15b886f460919ea3dce425a621dc017c2992a96b this is happening in testForcepoint93, but only on WNT. The crash is in SwObjectFormatterTextFrame::DoFormatObj() calling SwObjectFormatterTextFrame::InvalidateFollowObjs() and the mrPageFrame has been deleted; there is also the m_bAgain flag set in the SwLayAction up the stack, but the SwObjectFormatter::mpLayAction is null so DoFormatObj() cannot check this condition. In the caller CalcContent(), get the SwLayAction from the SwViewShell and pass it to the SwObjectFormatter, which appears to fix the problem. Change-Id: Ib3dc34ce39b4aad723251271c24bdd7a6598ab1c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159518 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 83cbf0757c96..47f2eddbc42d 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3480,15 +3480,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint91) { createSwWebDoc("forcepo //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint92) { createSwDoc("forcepoint92.doc"); } -#ifndef _MSC_VER -//FIXME: crashes only on WNT with RTF import changes - debug next week //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint93) { createSwDoc("forcepoint93-1.rtf"); createSwDoc("forcepoint93-2.rtf"); } -#endif //just care it doesn't crash/assert CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testForcepoint94) { createSwWebDoc("forcepoint94.html"); } diff --git a/sw/source/core/inc/objectformatter.hxx b/sw/source/core/inc/objectformatter.hxx index 99d8644f2c29..f85c12dc5f2d 100644 --- a/sw/source/core/inc/objectformatter.hxx +++ b/sw/source/core/inc/objectformatter.hxx @@ -166,7 +166,8 @@ class SwObjectFormatter */ static bool FormatObj( SwAnchoredObject& _rAnchoredObj, SwFrame* _pAnchorFrame = nullptr, - const SwPageFrame* _pPageFrame = nullptr ); + const SwPageFrame* _pPageFrame = nullptr, + SwLayAction* pLayAction = nullptr ); }; #endif diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 33880623a481..8dad5a5ad047 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -1566,7 +1566,8 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA // Thus, <bNoCalcFollow> no longer used by <FormatWidthCols(..)>. void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) { - vcl::RenderContext* pRenderContext = pLay->getRootFrame()->GetCurrShell()->GetOut(); + SwViewShell & rShell(*pLay->getRootFrame()->GetCurrShell()); + vcl::RenderContext* pRenderContext = rShell.GetOut(); SwSectionFrame* pSect; bool bCollect = false; if( pLay->IsSctFrame() ) @@ -1727,7 +1728,8 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) } } - if ( !SwObjectFormatter::FormatObj( *pAnchoredObj, pAnchorFrame, pAnchorPageFrame ) ) + if (!SwObjectFormatter::FormatObj(*pAnchoredObj, pAnchorFrame, pAnchorPageFrame, + rShell.Imp()->IsAction() ? &rShell.Imp()->GetLayAction() : nullptr)) { bRestartLayoutProcess = true; break; diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index b99da6a0fe4b..6395d2f9e3a8 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -167,7 +167,8 @@ bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& _rAnchorFrame, */ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj, SwFrame* _pAnchorFrame, - const SwPageFrame* _pPageFrame ) + const SwPageFrame* _pPageFrame, + SwLayAction * pLayAction) { bool bSuccess( true ); @@ -181,7 +182,7 @@ bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj, // create corresponding object formatter std::unique_ptr<SwObjectFormatter> pObjFormatter = - SwObjectFormatter::CreateObjFormatter( rAnchorFrame, rPageFrame, nullptr/*_pLayAction*/ ); + SwObjectFormatter::CreateObjFormatter(rAnchorFrame, rPageFrame, pLayAction); if ( pObjFormatter ) {