2.8.0 Gtk2: Assert on wxListBox::SetString()
Vadim Zeitlin
vadim at wxwindows.org
Thu Apr 12 06:58:52 PDT 2007
On Thu, 12 Apr 2007 09:19:26 +0200 Thomas Zehbe <tz at ingenion.de> wrote:
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 but you can easily work around this problem by just testing if
the selection is valid.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list