From bee5ccc4aaf0d2d5c9adb31b1bfe8f3f3f356b8e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 12 Mar 2003 19:48:45 +0000 Subject: [PATCH] Prevent crash in case nothing is selected git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/checklst.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 42ffa063a1..1b95e98a2a 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -298,7 +298,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, return wxListBox::Create(parent, id, pos, size, n, choices, style | wxLB_OWNERDRAW, validator, name); } - + void wxCheckListBox::Delete(int N) @@ -408,15 +408,19 @@ void wxCheckListBox::OnKeyDown(wxKeyEvent& event) if ( oper != None ) { wxArrayInt selections; - int count; + int count = 0; if ( HasMultipleSelection() ) { count = GetSelections(selections); } else { - count = 1; - selections.Add(GetSelection()); + int sel = GetSelection(); + if (sel != -1) + { + count = 1; + selections.Add(sel); + } } for ( int i = 0; i < count; i++ )