Fix bug in workaround for event handlers deleting wxGrid cells

The changes of e6e6dbe077 (Fix problems due to deleting grid cells in
the event handlers, 2020-05-02) fixed the bug (see #18731), but
introduced another one in place: if wxEVT_GRID_CELL_CHANGED handler
deleted any cells, wxGrid code could mistakenly restore the "old" cell
value (actually it restored the value for a different cell, as the
current cell coordinates necessarily changed too in this case).

This bug became more visible after the addition of activatable editors
as the new code asserts, instead of trying to restore the old value, if
wxEVT_GRID_CELL_CHANGED is vetoed, which also resulted in asserts if the
handler deleted the current cell instead.

Fix this by separating the cases of event being really vetoed and of the
event handler deleting the cell for which the event was generated and
handle the latter separately from the former where it matters.

This commit is best viewed ignoring whitespace changes.
This commit is contained in:
Vadim Zeitlin
2020-06-30 19:04:52 +02:00
parent f877106663
commit 8445d1993e
2 changed files with 66 additions and 32 deletions

View File

@@ -2789,9 +2789,10 @@ protected:
enum EventResult
{
Event_Vetoed = -1, // Also returned when cell was deleted.
Event_Vetoed = -1,
Event_Unhandled,
Event_Handled
Event_Handled,
Event_CellDeleted // Event handler deleted the cell.
};
// Send the given grid event and returns one of the event handling results