sw/source/core/layout/findfrm.cxx               |   15 ++++++++++-----
 sw/source/core/layout/flycnt.cxx                |    1 -
 sw/source/core/layout/objectformatter.cxx       |    2 +-
 sw/source/core/layout/objectformattertxtfrm.cxx |   17 ++++++++++-------
 4 files changed, 21 insertions(+), 14 deletions(-)

New commits:
commit 4eaa50802d724b8744218c8993364fe7b6f03eaa
Author:     Matt K <matt...@gmail.com>
AuthorDate: Mon Jan 15 19:30:37 2024 -0600
Commit:     Matt K <matt...@gmail.com>
CommitDate: Mon Jan 29 16:30:14 2024 +0100

    tdf#154863 Fix crashes when moving images in a large document
    
    The problem is that when moving images around the code tries
    to do things with anchored text frames that have already gone
    through destruction.  The fix is to check if those frames have
    the destruction bit set before using them, thus avoiding the
    crashes.
    
    Also, there is an assert that was firing and removing it
    seems to have no negative effect in interacting with the file.
    
    Change-Id: I899171ef3b5113f479725b0421f469c36e40e26c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162151
    Reviewed-by: Matt K <matt...@gmail.com>
    Tested-by: Matt K <matt...@gmail.com>

diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index 5331baacd93e..4df108ccf170 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -235,12 +235,17 @@ bool SwLayoutFrame::IsAnLower( const SwFrame *pAssumed ) 
const
     const SwFrame *pUp = pAssumed;
     while ( pUp )
     {
-        if ( pUp == this )
-            return true;
-        if ( pUp->IsFlyFrame() )
-            pUp = static_cast<const SwFlyFrame*>(pUp)->GetAnchorFrame();
+        if (!pUp->IsInDtor())
+        {
+            if (pUp == this)
+                return true;
+            if (pUp->IsFlyFrame())
+                pUp = static_cast<const SwFlyFrame*>(pUp)->GetAnchorFrame();
+            else
+                pUp = pUp->GetUpper();
+        }
         else
-            pUp = pUp->GetUpper();
+            break;
     }
     return false;
 }
diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx
index 2ed6fbf08942..1913ef6c0f81 100644
--- a/sw/source/core/layout/flycnt.cxx
+++ b/sw/source/core/layout/flycnt.cxx
@@ -1474,7 +1474,6 @@ void SwFlyAtContentFrame::RegisterAtCorrectPage()
 
 void SwFlyAtContentFrame::RegisterAtPage(SwPageFrame & rPageFrame)
 {
-    assert(GetPageFrame() != &rPageFrame);
     if (GetPageFrame())
     {
         GetPageFrame()->MoveFly( this, &rPageFrame );
diff --git a/sw/source/core/layout/objectformatter.cxx 
b/sw/source/core/layout/objectformatter.cxx
index 6395d2f9e3a8..547aa3c550d5 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -364,7 +364,7 @@ bool SwObjectFormatter::FormatObjsAtFrame_( SwTextFrame* 
_pMasterTextFrame )
     {
         pAnchorFrame = &GetAnchorFrame();
     }
-    if ( !pAnchorFrame->GetDrawObjs() )
+    if ( !pAnchorFrame->GetDrawObjs() || pAnchorFrame->IsInDtor() )
     {
         // nothing to do, if no floating screen object is registered at the 
anchor frame.
         return true;
diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx 
b/sw/source/core/layout/objectformattertxtfrm.cxx
index 9a44b0df624b..1b71301e7adb 100644
--- a/sw/source/core/layout/objectformattertxtfrm.cxx
+++ b/sw/source/core/layout/objectformattertxtfrm.cxx
@@ -926,14 +926,17 @@ void 
SwObjectFormatterTextFrame::FormatAnchorFrameAndItsPrevs( SwTextFrame& _rAn
     // format anchor frame - format of its follow not needed
     // #i43255# - forbid follow format, only if anchor text
     // frame is in table
-    if ( _rAnchorTextFrame.IsInTab() )
+    if (!_rAnchorTextFrame.IsInDtor())
     {
-        SwForbidFollowFormat aForbidFollowFormat( _rAnchorTextFrame );
-        
_rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
-    }
-    else
-    {
-        
_rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
+        if (_rAnchorTextFrame.IsInTab())
+        {
+            SwForbidFollowFormat aForbidFollowFormat(_rAnchorTextFrame);
+            
_rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
+        }
+        else
+        {
+            
_rAnchorTextFrame.Calc(_rAnchorTextFrame.getRootFrame()->GetCurrShell()->GetOut());
+        }
     }
 }
 

Reply via email to