Fix problems due to deleting grid cells in the event handlers

Deleting last grid rows or column in a few event handlers could result
in asserts/crashes in wxGrid code if the event handler also called
event.Skip(), as wxGrid still tried to perform the default action using
the deleted cell, when these events happened in the last row or column.

It's not totally clear whether calling event.Skip() after performing an
action modifying the grid should be allowed at all, but, in doubt, at
least avoid crashing if it does happen, by considering the event as
being handled (and even vetoed) if its handler deleted the cell in which
it was generated.

Closes #18731.
This commit is contained in:
Vadim Zeitlin
2020-05-02 00:53:59 +02:00
parent 5cdcfddc61
commit e6e6dbe077
2 changed files with 13 additions and 3 deletions

View File

@@ -2553,8 +2553,10 @@ protected:
bool Redimension( wxGridTableMessage& );
// Send the given grid event and return -1 if it was vetoed, 1 if
// it was processed (but not vetoed) and 0 if it wasn't processed.
// Send the given grid event and return -1 if it was vetoed or, as a
// special exception, if an event for a particular cell resulted in this
// cell being deleted, 1 if it was processed (but not vetoed) and 0 if it
// wasn't processed.
int DoSendEvent(wxGridEvent& gridEvt);
// Generate an event of the given type and call DoSendEvent().