From 032b29619484a2a4ade0600cd978df86d5d522a5 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 7 Sep 2012 10:00:44 +0200 Subject: fdo#54620 do not use vector iterator after insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5e809f38a500ab818e9acef80b419dfece7a29fa (cherry picked from commit 06ae26b5676c29c4d1cc9c65f5bbaede9483a21d) Signed-off-by: Caolán McNamara --- sw/source/core/doc/gctable.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/doc/gctable.cxx b/sw/source/core/doc/gctable.cxx index 5507c54a36cb..f71cb2af1c44 100644 --- a/sw/source/core/doc/gctable.cxx +++ b/sw/source/core/doc/gctable.cxx @@ -357,19 +357,20 @@ static bool lcl_MergeGCBox(SwTableBox* pTblBox, void*const pPara) if( 1 == pTblBox->GetTabLines().Count() ) { - // Box with a Line, then move all the Line's Boxes after this Box - // into the parent Line and delete this Box + // we have a box with a single line, so we just replace it by the line's boxes SwTableLine* pInsLine = pTblBox->GetUpper(); SwTableLine* pCpyLine = pTblBox->GetTabLines()[0]; SwTableBoxes::iterator it = std::find( pInsLine->GetTabBoxes().begin(), pInsLine->GetTabBoxes().end(), pTblBox ); for( n = 0; n < pCpyLine->GetTabBoxes().size(); ++n ) pCpyLine->GetTabBoxes()[n]->SetUpper( pInsLine ); - pInsLine->GetTabBoxes().insert( it + 1, pCpyLine->GetTabBoxes().begin(), pCpyLine->GetTabBoxes().end()); + // remove the old box from its parent line + it = pInsLine->GetTabBoxes().erase( it ); + // insert the nested line's boxes in its place + pInsLine->GetTabBoxes().insert( it, pCpyLine->GetTabBoxes().begin(), pCpyLine->GetTabBoxes().end()); pCpyLine->GetTabBoxes().clear(); - // Delete the old Box with the Line - delete *it; - pInsLine->GetTabBoxes().erase( it ); + // destroy the removed box + delete pTblBox; return false; // set up anew } -- cgit v1.2.3