summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2012-09-18 14:19:50 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-09-19 09:12:48 +0000
commitd60ea419c57812f611125b0ca51bf897ea7e214b (patch)
treeba96493961f3b710f711b0bf878c96212e34cf2a
parente80b2d5d6caf50f9c7f48e1b532e7d6fddeb4e45 (diff)
rhbz#852128: sw: avoid table undo crash:
SwUndoTblNdsChg::UndoImpl: to prevent access of deleted table box start node, disconnect the SwTableBox from the start node before removing the table box nodes. This problem was probably introduced with CWS swnewtable db4de0817df6906db2743239d45f9f0834ab1e91, which changed the order of the removal operations for unknown reasons. (cherry picked from commit cf842d7c7f9559bfdbb3924cd05a3a50d1dff5e3) Conflicts: sw/source/core/table/swtable.cxx Change-Id: Ic59823a84082cc6ff453b2b512cbb8253886ecf3 Reviewed-on: https://gerrit.libreoffice.org/640 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--sw/inc/swtable.hxx1
-rw-r--r--sw/source/core/table/swtable.cxx14
-rw-r--r--sw/source/core/undo/untbl.cxx5
3 files changed, 17 insertions, 3 deletions
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 29c779a51ed2..a3525882c142 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -422,6 +422,7 @@ public:
422 SwFrmFmt* ClaimFrmFmt(); 422 SwFrmFmt* ClaimFrmFmt();
423 void ChgFrmFmt( SwTableBoxFmt *pNewFmt ); 423 void ChgFrmFmt( SwTableBoxFmt *pNewFmt );
424 424
425 void RemoveFromTable();
425 const SwStartNode *GetSttNd() const { return pSttNd; } 426 const SwStartNode *GetSttNd() const { return pSttNd; }
426 sal_uLong GetSttIdx() const; 427 sal_uLong GetSttIdx() const;
427 428
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 3a57a7586b4f..69e755b09a70 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1747,10 +1747,9 @@ SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, const SwStartNode& rSttNd, SwTableL
1747 rSrtArr.Insert( p ); // eintragen 1747 rSrtArr.Insert( p ); // eintragen
1748} 1748}
1749 1749
1750SwTableBox::~SwTableBox() 1750void SwTableBox::RemoveFromTable()
1751{ 1751{
1752 // Inhaltstragende Box ? 1752 if (pSttNd) // box containing contents?
1753 if( !GetFrmFmt()->GetDoc()->IsInDtor() && pSttNd )
1754 { 1753 {
1755 // an der Table austragen 1754 // an der Table austragen
1756 const SwTableNode* pTblNd = pSttNd->FindTableNode(); 1755 const SwTableNode* pTblNd = pSttNd->FindTableNode();
@@ -1759,6 +1758,15 @@ SwTableBox::~SwTableBox()
1759 GetTabSortBoxes(); 1758 GetTabSortBoxes();
1760 SwTableBox *p = this; // error: &this 1759 SwTableBox *p = this; // error: &this
1761 rSrtArr.Remove( p ); // austragen 1760 rSrtArr.Remove( p ); // austragen
1761 pSttNd = 0; // clear it so this is only run once
1762 }
1763}
1764
1765SwTableBox::~SwTableBox()
1766{
1767 if (!GetFrmFmt()->GetDoc()->IsInDtor())
1768 {
1769 RemoveFromTable();
1762 } 1770 }
1763 1771
1764 // ist die TabelleBox der letzte Client im FrameFormat, kann dieses 1772 // ist die TabelleBox der letzte Client im FrameFormat, kann dieses
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 11dbb4b7eeaa..e3a6af5d7a6a 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1755,7 +1755,11 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
1755 rDoc.GetNodes()._MoveNodes( aRg, rDoc.GetNodes(), aInsPos, sal_False ); 1755 rDoc.GetNodes()._MoveNodes( aRg, rDoc.GetNodes(), aInsPos, sal_False );
1756 } 1756 }
1757 else 1757 else
1758 { // first disconnect box from node, otherwise ~SwTableBox would
1759 // access pBox->pSttNd, deleted by DeleteSection
1760 pBox->RemoveFromTable();
1758 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] ); 1761 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
1762 }
1759 aDelBoxes.insert( aDelBoxes.end(), pBox ); 1763 aDelBoxes.insert( aDelBoxes.end(), pBox );
1760 } 1764 }
1761 } 1765 }
@@ -1771,6 +1775,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
1771 // TL_CHART2: notify chart about box to be removed 1775 // TL_CHART2: notify chart about box to be removed
1772 if (pPCD) 1776 if (pPCD)
1773 pPCD->DeleteBox( &pTblNd->GetTable(), *pBox ); 1777 pPCD->DeleteBox( &pTblNd->GetTable(), *pBox );
1778 pBox->RemoveFromTable(); // ~SwTableBox would access pBox->pSttNd
1774 aDelBoxes.insert( aDelBoxes.end(), pBox ); 1779 aDelBoxes.insert( aDelBoxes.end(), pBox );
1775 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] ); 1780 rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
1776 } 1781 }