]> git.saurik.com Git - wxWidgets.git/commitdiff
avoid asserts by not using GetSelection() with multi selection listbox
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Jun 2006 23:25:18 +0000 (23:25 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Jun 2006 23:25:18 +0000 (23:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/controls/controls.cpp

index 6db449617942ac7d3dbbe772f6dba435d6aaaba1..8435a9801c692801a5c3d8a83870258f8831d0e3 100644 (file)
@@ -1218,8 +1218,6 @@ void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
 
 void MyPanel::OnListBox( wxCommandEvent &event )
 {
-//    GetParent()->Move(100, 100);
-
     if (event.GetInt() == -1)
     {
         m_text->AppendText( _T("ListBox has no selections anymore\n") );
@@ -1232,9 +1230,15 @@ void MyPanel::OnListBox( wxCommandEvent &event )
     m_text->AppendText( _T("ListBox event selection string is: '") );
     m_text->AppendText( event.GetString() );
     m_text->AppendText( _T("'\n") );
-    m_text->AppendText( _T("ListBox control selection string is: '") );
-    m_text->AppendText( listbox->GetStringSelection() );
-    m_text->AppendText( _T("'\n") );
+
+    // can't use GetStringSelection() with multiple selections, there could be
+    // more than one of them
+    if ( !listbox->HasFlag(wxLB_MULTIPLE) )
+    {
+        m_text->AppendText( _T("ListBox control selection string is: '") );
+        m_text->AppendText( listbox->GetStringSelection() );
+        m_text->AppendText( _T("'\n") );
+    }
 
     wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
     m_text->AppendText( _T("ListBox event client data string is: '") );
@@ -1245,7 +1249,7 @@ void MyPanel::OnListBox( wxCommandEvent &event )
 
     m_text->AppendText( _T("'\n") );
     m_text->AppendText( _T("ListBox control client data string is: '") );
-    obj = (wxStringClientData *)listbox->GetClientObject(listbox->GetSelection());
+    obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt());
     if (obj)
         m_text->AppendText( obj->GetData() );
     else