Apache OpenOffice (AOO) Bugzilla – Issue 74780
Crash on Undo of merging cells in complex table
Last modified: 2013-08-07 14:43:17 UTC
Open attached document, merge cells B2.1.1 and B2.1.2, Undo -> crash
Created attachment 43278 [details] Sample document
Changing Prio to P2.
The bookmark in the merged cell causes the trouble.I will wait until swnewtable is integrated before I fix the problem to minimize resync effort.
Created attachment 50415 [details] patch file
liuyu->ama: This patch solved crash, but after undoing something wrong in the SwBookmarks. I am trying to fix it.
This patch would cause a memory leak because these (bookmark) undo objects will never be destroyed. You will need to collect them and call their undo/redo at the right moment within the SwUndoTblMerge object.
Created attachment 50453 [details] patch file
liuyu->ama: Please have a look at the new patch. I found that the node index of the node which contains the bookmark named 'howtouse' is 35 before merging the two table boxes, and it is 27 after merging, I know that's because of the moving of this node when merging. But it is 30 when undoing the merging( after moving the node to the position before merging). So the bookmark(howtouse) would be inserted to a wrong postion. Why it is not 35, same as its index before? Is the reason of the different index the deleted bookmark?
ama->liuyu: the problem is a quiet strange behavior of the SwUndoTblMerge. It has its own list of undo operations (SwUndoMove) which are not in the normal undo stack. On the other side the bookmark manipulations are recorded on the normal undo stack. This does not fit together. So the idea of your patch to redo the recorded bookmark-undos point in the right direction even this patch would work perfectly. But I found another, radical solution. First I removed the SwUndoTblMerge::MoveBoxCntnt(SwPaM ..) method. It was only called in tblsel.cxx and I changed this, too. So now we cannot crash in this function any longer ;-) Instead of this I use the SwUndoTblMerge::MoveBoxCntnt(SwDoc*...) function. We lost only a crude behavior of old tables which nobody really needed or understood. So far, so good. But even this other method has problems caused by the bookmark undo objects. My solution is to disable the undo recording inside SwUndoTblMerge::MoveBoxCntnt(..) and all works fine!
Fixed in CWS sw8u10bf04 undobj.hxx untbl.cxx tblsel.cxx
Ready for QA.
Verified fix in CWS sw8u10bf04.
Checked fix in SRC680m245 and OOH680m7.