[BUG] ItemListbox::removeItem(), ::getFirstSelectedItem()

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

[BUG] ItemListbox::removeItem(), ::getFirstSelectedItem()

Postby Jamarr » Wed Jun 11, 2008 16:26

Basically, when you call ItemListbox::removeItem() it doesn't check to see if the item you are removing is currently selected (ItemListbox::d_lastSelected). So if you then call ItemListbox::getFirstSelectedItem() it returns an invalid pointer (assuming DestroyedByParent(True)). This was probably missed because removeItem() is actually derived from ItemListBase, which has no knowledge of ItemListbox::d_lastSelected.

This can be easily reproduced:

Code: Select all

...
CEGUI::WindowManager& cMan = CEGUI::WindowManager::getSingleton();
// note memory address
CEGUI::ItemListbox* pList = static_cast<CEGUI::ItemListbox*> (cMan.getWindow("EditChecklist/Frame/ItemListbox/Checklist"));

CEGUI::ItemEntry* pItem = (CEGUI::ItemEntry*)(CEGUI::WindowManager::getSingleton().createWindow("WindowsLook/ListboxItem"));
pList->addItem(pItem);
pItem->select();
pList->removeItem(pItem);

// should return 0, but instead returns the memory address for the item that was just removed!
pItem = pList->getFirstSelectedItem();

if (pItem)
pItem->setText("Test"); // crash and burn...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jun 11, 2008 17:47

Hi,

Thanks for the report - it is very much appreciated. I have added the bug to our mantis tracker:
http://www.cegui.org.uk/mantis/view.php?id=206 It will be fixed in the upcoming 0.6.1 maintenance release.

CE.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Wed Jun 11, 2008 19:13

Would you guys prefer if I submitted any future bugs into the Mantis Tracker myself, or should I just continue to use this forum?

You probably don't care either way, but I'm guessing it'd be less effort on your part if I just put it directly into the bug tracker myself.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Jun 12, 2008 08:19

Hi,

If you're 99% sure it's a bug, then feel free to submit directly on Mantis; the only thing we want to avoid on there is having a load of non-bugs / non-feature requests that make it hard to find the real issues :)

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 6 guests