[ wxwindows-Bugs-1478041 ] wxListCtrl and wxImageList bug
SourceForge.net
noreply at sourceforge.net
Mon Jun 4 00:47:07 PDT 2007
Bugs item #1478041, was opened at 2006-04-27 22:26
Message generated for change (Settings changed) made by roebling
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1478041&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Generic
Group: Must fix
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Hartwig Wiesmann (hwiesmann)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxListCtrl and wxImageList bug
Initial Comment:
Hi!
The code below does the following:
It creates a list in report view with one row that is first added,
afterwards deleted and added again. One column of the list has got an
image attached. There is always an image list attached to the list
control.
When adding for the second time an element to the list, the code will
crash (reason given after the code snippet).
Suppose I have got the following code:
wxListCtrl* ListCtrlPtr(new wxListCtrl(...));
wxImageList* ImageList(new wxImageList(16,16));
ImageList->Add(wxBitmap(...));
ListCtrl->AssignImageList(ImageList,wxIMAGE_LIST_SMALL);
// add for the first time an item:
ListCtrl->InsertItem(0,wxString());
ListCtrl->SetItemColumnImage(0,0,0);
// delete it again:
ListCtrl->DeleteItem(0);
// also delete the item from the image list:
ListCtrl->GetImageList(wxIMAGE_LIST_SMALL)->Remove(0);
// add an item again:
ListCtrl->InsertItem(0,wxString()); // ASSERT, BUG!!
The problem seems to be that
wxListCtrl::InsertItem(int,wxString const&) initializes
wxListItem::m_image with 0 to indicate a non-existing image while the
internal method
wxListMainWindow::GetItemWidthWithImage(wxListItem*) compares
wxListItem::m_image with -1 to check if an image exists.
The reason why it did not crash in the first case is that the image list
had an element while in the second case the image list is empty.
The code does NOT crash if there is a rule that empty image lists are
not allowed. But this does not make sense.
Solution for this bug: set wxListItem::m_image to -1
(but I do not know if any function check the variable against 0)
Hartwig
----------------------------------------------------------------------
Comment By: Hartwig Wiesmann (hwiesmann)
Date: 2007-06-04 05:38
Message:
Logged In: YES
user_id=1190438
Originator: YES
Can you please close this bug as it seems to be solved, now (see 1727909).
Actually, I did not know that I have submitted this bug earlier.
Hartwig
----------------------------------------------------------------------
Comment By: Hartwig Wiesmann (hwiesmann)
Date: 2006-04-30 15:58
Message:
Logged In: YES
user_id=1190438
Hi,
I do not know what wxMSW does because I am using only MacOSX.
Hartwig
----------------------------------------------------------------------
Comment By: Robert Roebling (roebling)
Date: 2006-04-30 10:20
Message:
Logged In: YES
user_id=77100
What does wxMSW do here? If you e.g. add an item without an
image to an wxMSW wxListCtrl and then query it image index,
will it return -1?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1478041&group_id=9863
More information about the wx-dev
mailing list