[2.7.0] bug in wxListCtrl or undocumented feature
H
H at h.com
Tue Sep 5 13:14:14 PDT 2006
Hi!
These statements lead to an assert in "wxListBase::Item(unsigned long)
const":
ListCtrlPtr = new wxListCtrl(...);
ListCtrlPtr->AssignImageList(new wxImageList(wxSize(100,100),
::wxIMAGE_LIST_SMALL);
ListCtrlPtr->InsertItem(0,...);
ListCtrlPtr->GetImageList(::wxIMAGE_LIST_SMALL)->Add(wxBitmap()...);
ListCtrlPtr->SetItemColumnImage(...);
The reason for the assert is that wxWidget tries to calculate a
geometrical size for an image associated with the first item (with index
0). But in the image list there is no item, yet.
Modifying the statement order to
ListCtrlPtr = new wxListCtrl(...);
ListCtrlPtr->InsertItem(0,...);
ListCtrlPtr->AssignImageList(new wxImageList(wxSize(100,100),
::wxIMAGE_LIST_SMALL);
ListCtrlPtr->GetImageList(::wxIMAGE_LIST_SMALL)->Add(wxBitmap()...);
ListCtrlPtr->SetItemColumnImage(...);
is an intermediate workaround but not a solution. The reason is that
there is no possibility to add an item to the list with a new image
afterwards. If you extend the image list first you will get a complaint
that the image list contains more items than the list itself, if you
append an item to the list first you will get the before mentioned
assert message.
The only possibility is to first remove the image list completely, add
the item and then build up from scratch the image list again. But this
is not a real solution.
Hartwig
More information about the wx-users
mailing list