2.8.0 Gtk2: Assert on wxListBox::SetString()
Robert Roebling
robert at roebling.de
Thu Apr 12 12:01:00 PDT 2007
> TZ> I missed your answer yesterday. I took the listbox sample of the 2.8.3 Gtk
> TZ> Unicode Version and modified the ecenthandler like this:
> TZ> void LboxTestFrame::OnListbox(wxCommandEvent& event)
> TZ> {
> TZ> int sel = event.GetInt();
> TZ> m_textDelete->SetValue(wxString::Format(_T("%d"), sel));
> TZ>
> TZ> wxLogMessage(_T("Listbox item %d selected"), sel);
> TZ> wxString str(_T("this is new text"));
> TZ> m_lbox->SetString(sel, str);
> TZ> }
> TZ>
> TZ> Exactly the same assert occurs as in my app.
>
> This is because you get an event for the item -1 being selected.
> If you insert a "if ( sel != -1 )" test before calling SetString()
> the program works just as expected.
>
> Of course, ideally, there should be no selection changed events
> generated just by calling SetString() (currently there are some
> because SetString() deletes the old string and then inserts the
> new one) and I'll try to fix this in HEAD
As per Ryan comment in wxListBox::SetString(), is the listbox
supposed to resort after SetString()? In that case it might
really be easier to insert and readd the string and block
events while doing that.
Robert
More information about the wx-users
mailing list