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

Michael Stahl mstahl at redhat.com
Fri Sep 22 22:49:35 UTC 2017


 sw/source/core/docnode/ndtbl.cxx |    2 ++
 sw/source/core/fields/ddetbl.cxx |   11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 7597a4915d68da04f234f5fd2186287a17a94a5d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Sep 23 00:19:21 2017 +0200

    sw: actually SetTableNode() ought to always be called before delete
    
    Change-Id: I5e830e91ae7c773ad3945550c640a190b6504796

diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 4680323f0068..0047f22f8296 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -65,10 +65,13 @@ SwDDETable::~SwDDETable()
 {
     SwDDEFieldType* pFieldTyp = static_cast<SwDDEFieldType*>(aDepend.GetRegisteredIn());
     SwDoc* pDoc = GetFrameFormat()->GetDoc();
-    if (!pDoc->IsInDtor() && !m_aLines.empty() &&
-        m_pTableNode && m_pTableNode->GetNodes().IsDocNodes())
+    if (!pDoc->IsInDtor() && !m_aLines.empty())
     {
-        pFieldTyp->DecRefCnt();
+        assert(m_pTableNode);
+        if (m_pTableNode->GetNodes().IsDocNodes())
+        {
+            pFieldTyp->DecRefCnt();
+        }
     }
 
     // If it is the last dependent of the "deleted field" than delete it finally
commit 02b406b5cbc1c631b794154e5169838edbe3e2b5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 22 23:54:08 2017 +0200

    sw: fix crash on loading tdf109006-1.odt
    
    ~SwDDETable() accesses its boxes' start node but that follows the
    SwTableNode and SwNodes::RemoveNode() counts backwards so the
    box nodes are all dead.  This was always broken but spontaneously
    started to crash today.
    
    Because dtors don't have parameters, resort to a little subterfuge
    to ensure ~SwDDETable() finds out where it is.
    
    Change-Id: Id681005989dd1e9f2611e8c99841927a7c5f6bfa

diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index a1340bcfa78e..d77518100c33 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2366,6 +2366,7 @@ SwTableNode::~SwTableNode()
                                 pTableFormat );
     pTableFormat->ModifyNotification( &aMsgHint, &aMsgHint );
     DelFrames();
+    m_pTable->SetTableNode(this); // set this so that ~SwDDETable can read it!
     delete m_pTable;
 }
 
@@ -2485,6 +2486,7 @@ void SwTableNode::DelFrames()
 void SwTableNode::SetNewTable( SwTable* pNewTable, bool bNewFrames )
 {
     DelFrames();
+    m_pTable->SetTableNode(this);
     delete m_pTable;
     m_pTable = pNewTable;
     if( bNewFrames )
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index 5543f05ceac9..4680323f0068 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -65,9 +65,11 @@ SwDDETable::~SwDDETable()
 {
     SwDDEFieldType* pFieldTyp = static_cast<SwDDEFieldType*>(aDepend.GetRegisteredIn());
     SwDoc* pDoc = GetFrameFormat()->GetDoc();
-    if( !pDoc->IsInDtor() && !m_aLines.empty() &&
-        GetTabSortBoxes()[0]->GetSttNd()->GetNodes().IsDocNodes() )
+    if (!pDoc->IsInDtor() && !m_aLines.empty() &&
+        m_pTableNode && m_pTableNode->GetNodes().IsDocNodes())
+    {
         pFieldTyp->DecRefCnt();
+    }
 
     // If it is the last dependent of the "deleted field" than delete it finally
     if( pFieldTyp->IsDeleted() && pFieldTyp->HasOnlyOneListener() )


More information about the Libreoffice-commits mailing list