summaryrefslogtreecommitdiff
authorMichael Stahl <mst@openoffice.org>2012-09-18 12:19:50 (GMT)
committer Miklos Vajna <vmiklos@suse.cz>2012-09-19 09:12:48 (GMT)
commitd60ea419c57812f611125b0ca51bf897ea7e214b (patch) (side-by-side diff)
treeba96493961f3b710f711b0bf878c96212e34cf2a
parente80b2d5d6caf50f9c7f48e1b532e7d6fddeb4e45 (diff)
downloadcore-d60ea419c57812f611125b0ca51bf897ea7e214b.zip
core-d60ea419c57812f611125b0ca51bf897ea7e214b.tar.gz
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>
Diffstat (more/less context) (ignore whitespace changes)
-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 29c779a..a352588 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -422,6 +422,7 @@ public:
SwFrmFmt* ClaimFrmFmt();
void ChgFrmFmt( SwTableBoxFmt *pNewFmt );
+ void RemoveFromTable();
const SwStartNode *GetSttNd() const { return pSttNd; }
sal_uLong GetSttIdx() const;
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 3a57a75..69e755b 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
rSrtArr.Insert( p ); // eintragen
}
-SwTableBox::~SwTableBox()
+void SwTableBox::RemoveFromTable()
{
- // Inhaltstragende Box ?
- if( !GetFrmFmt()->GetDoc()->IsInDtor() && pSttNd )
+ if (pSttNd) // box containing contents?
{
// an der Table austragen
const SwTableNode* pTblNd = pSttNd->FindTableNode();
@@ -1759,6 +1758,15 @@ SwTableBox::~SwTableBox()
GetTabSortBoxes();
SwTableBox *p = this; // error: &this
rSrtArr.Remove( p ); // austragen
+ pSttNd = 0; // clear it so this is only run once
+ }
+}
+
+SwTableBox::~SwTableBox()
+{
+ if (!GetFrmFmt()->GetDoc()->IsInDtor())
+ {
+ RemoveFromTable();
}
// 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 11dbb4b..e3a6af5 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)
rDoc.GetNodes()._MoveNodes( aRg, rDoc.GetNodes(), aInsPos, sal_False );
}
else
+ { // first disconnect box from node, otherwise ~SwTableBox would
+ // access pBox->pSttNd, deleted by DeleteSection
+ pBox->RemoveFromTable();
rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
+ }
aDelBoxes.insert( aDelBoxes.end(), pBox );
}
}
@@ -1771,6 +1775,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
// TL_CHART2: notify chart about box to be removed
if (pPCD)
pPCD->DeleteBox( &pTblNd->GetTable(), *pBox );
+ pBox->RemoveFromTable(); // ~SwTableBox would access pBox->pSttNd
aDelBoxes.insert( aDelBoxes.end(), pBox );
rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
}