Avoids asserts in the listctrl sample on pressing Ctrl-I

Calling InsertItemInReportView() with invalid index results in a series
of asserts, so avoid doing this.

Note that there seems to be an unrelated bug in wxGTK which results in
this code being executed at all, as normally the definition of a menu
item using Ctrl-I as an accelerator should have prevented this from
happening.
This commit is contained in:
Vadim Zeitlin 2020-11-09 00:40:43 +01:00
parent 5ae2a8ebb8
commit a2ebe1928a

View File

@ -1435,7 +1435,10 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
} }
else // !virtual else // !virtual
{ {
InsertItemInReportView(event.GetIndex()); int idx = event.GetIndex();
if ( idx == -1 )
idx = 0;
InsertItemInReportView(idx);
} }
break; break;
} }