]> git.saurik.com Git - wxWidgets.git/commitdiff
Prevent crash in case nothing is selected
authorRobin Dunn <robin@alldunn.com>
Wed, 12 Mar 2003 19:48:45 +0000 (19:48 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 12 Mar 2003 19:48:45 +0000 (19:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/checklst.cpp

index db05ff7812308cc12b1a23f7a2eb87acd766d717..756293a0eda958c23c2ef1f0a9508e717460f9d2 100644 (file)
@@ -418,15 +418,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++ )