From a2ebe1928a3d5f17cf6fede87a472f9e53c0ebe7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Nov 2020 00:40:43 +0100 Subject: [PATCH] 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. --- samples/listctrl/listtest.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index a69bb77edd..92ae0a1926 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -1435,7 +1435,10 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event) } else // !virtual { - InsertItemInReportView(event.GetIndex()); + int idx = event.GetIndex(); + if ( idx == -1 ) + idx = 0; + InsertItemInReportView(idx); } break; }