Page 1 of 1

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

Posted: Wed Jun 11, 2008 16:26
by Jamarr
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...

Posted: Wed Jun 11, 2008 17:47
by CrazyEddie
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.

Posted: Wed Jun 11, 2008 19:13
by Jamarr
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.

Posted: Thu Jun 12, 2008 08:19
by CrazyEddie
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.