diff options
author | David Tardon <dtardon@redhat.com> | 2012-09-07 10:00:44 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2012-09-07 10:07:03 +0200 |
commit | 06ae26b5676c29c4d1cc9c65f5bbaede9483a21d (patch) | |
tree | 717539845fc350e073c45ed192f95ad05fc59ad1 | |
parent | dcae7058a707d7936c910d058afbad0f6220bb11 (diff) |
fdo#54620 do not use vector iterator after insert
Change-Id: I5e809f38a500ab818e9acef80b419dfece7a29fa
-rw-r--r-- | sw/source/core/doc/gctable.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sw/source/core/doc/gctable.cxx b/sw/source/core/doc/gctable.cxx index 0694be341fbd..6581000483f7 100644 --- a/sw/source/core/doc/gctable.cxx +++ b/sw/source/core/doc/gctable.cxx @@ -352,19 +352,20 @@ static bool lcl_MergeGCBox(SwTableBox* pTblBox, _GCLinePara* pPara) if( 1 == pTblBox->GetTabLines().size() ) { - // 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 } |