From 45262a34151f11b3c12f3b6c0da932bc8d4ea146 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 30 Jun 2006 23:25:18 +0000 Subject: [PATCH] avoid asserts by not using GetSelection() with multi selection listbox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/controls/controls.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 6db4496179..8435a9801c 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -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