[Libreoffice-commits] core.git: sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 1 09:13:40 UTC 2020


 sw/source/core/txtnode/ndtxt.cxx |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 138cf950dcdc8a1240452cad6867e197279f42b0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Nov 17 12:51:32 2020 +0000
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Dec 1 10:12:55 2020 +0100

    tdf#134626 assertion in ~SwTextNode
    
    taking the simplest example of...
    http://bugs.documentfoundation.org/attachment.cgi?id=167361
    
    a) on ctrl+v paste into the new document:
    
    DocumentContentOperationsManager::CopyImplImpl
    is called and that (at "Also copy all format templates")
    causes SwTextNode::ChgTextCollUpdateNum
    to call rDoc.GetNodes().UpdateOutlineNode(*this)
    
    so the new paragraph is now set as an outline node of the
    document DocNodes
    
    that seems perfectly reasonable
    
    b) ctrl+v again
    
    no new paragraph, text appended to node of a)
    
    c) ctrl+z
    
    SwUndoSaveContent::MoveToUndoNds is called
    and rNodes.MakeTextNode is called to make a
    new TextNode to move the content into.
    
    The SwNodes the TextNode is created in are rNds =
    rDoc.GetUndoManager().GetUndoNodes(), i.e. the undo nodes.
    
    MakeTextNode calls...
    SwTextNode *pNode = new SwTextNode( rWhere, pColl, nullptr )
    and the SwTextNode ctor unconditionally does...
    
    GetNodes().UpdateOutlineNode(*this);
    
    so its set as an outline node in those undo SwNodes
    
    In SwNodes::MakeTextNode right after the
    SwTextNode *pNode = new SwTextNode( rWhere, pColl, nullptr )
    call we have...
    
    // call method <UpdateOutlineNode(..)> only for the document nodes array
    if ( IsDocNodes() )
        UpdateOutlineNode(*pNode);
    
    That seems odd, because we have *already* unconditionally called
    UpdateOutlineNode in the SwTextNode ctor.
    
    d) ctrl+z
    The SwTextFormatColl is destroyed
    and SwTextNode::TriggerNodeUpdate
    is called for the TextNode of a) and is updated. It is also
    called for the TextNode of c) but due to...
    
    // #125329# - assure that text node is in document nodes array
    if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() )
    
    c is *not* updated, so on eventual dtor of c the assert fires.
    
    Change-Id: I56f9b00dd4665fd44359a01baef66c82937c2781
    
    ---
    
    If the conditional UpdateOutlineNode call in SwNodes::MakeTextNode is
    the right thing to do where only TextNodes in the DocNodes should be
    updated, then presumably the equivalent call in the SwTextNode
    ctor should be also conditional, making that MakeTextNode call redundant
    in any case.
    
    ChgTextCollUpdateNum always calls
    rDoc.GetNodes().UpdateOutlineNode(*this);
    which suggests that the SwTextNode::ChgFormatColl function should
    rely on that to call UpdateOutlineNode and not call it directly
    to also avoid a UpdateOutlineNode in the undo nodes
    
    Change-Id: Iedc3fb4d41c24dbbe41fbac259abe41d3757be09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106011
    Tested-by: Jenkins
    Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 8ebdc1322a68..c128973cdf63 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -110,10 +110,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & rWhere,
 
     SwNodeIndex aIdx( *pNode );
 
-    // call method <UpdateOutlineNode(..)> only for the document nodes array
-    if ( IsDocNodes() )
-        UpdateOutlineNode(*pNode);
-
     // if there is no layout or it is in a hidden section, MakeFrames is not needed
     const SwSectionNode* pSectNd;
     if (!bNewFrames ||
@@ -220,7 +216,10 @@ SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl *pTextColl,
         }
         AddToList();
     }
-    GetNodes().UpdateOutlineNode(*this);
+
+    // call method <UpdateOutlineNode(..)> only for the document nodes array
+    if (GetNodes().IsDocNodes())
+        GetNodes().UpdateOutlineNode(*this);
 
     m_bNotifiable = true;
 
@@ -3924,8 +3923,6 @@ SwFormatColl* SwTextNode::ChgFormatColl( SwFormatColl *pNewColl )
         ChgTextCollUpdateNum( pOldColl, static_cast<SwTextFormatColl *>(pNewColl) );
     }
 
-    GetNodes().UpdateOutlineNode(*this);
-
     return pOldColl;
 }
 


More information about the Libreoffice-commits mailing list