Ticket #15189 (closed defect: fixed)
wxRichTextCtrlTable: deleting the focused cell crashes
|Reported by:||dghart||Owned by:|
|Keywords:||wxRichTextCtrlTable delete cell crash||Cc:|
The attached diff to the 'richtext' sample makes running the 'About' dialog delete the last column of the table. Run the sample, click in one of the cells in that column, then do Help > About. The sample will segfault. The exact details vary depending with the calling code (and probably the machine and platform) but it occurs because the focus object is no longer valid when later calls (e.g. setting the caret) use it as 'container'. This happens in the current svn trunk but also in 2.9.4, so it's not the result of recent patches.
I don't know how to fix this. I don't think there's any way for later calls to predict that the object is disappearing. Always setting focus outside the table would probably work, but isn't user-friendly. The correct answer would be to detect that the focused cell is about to be killed and set focus elsewhere in the table. However afaict there's no way to tell which cell _has_ focus: the cell itself doesn't know, and e.g. GetCaretPosition() returns only the position within the cell. I hope I'm missing something...