Page 1 of 1

Error in ListboxTextItem

Posted: Thu Nov 06, 2008 18:53
by leonardoalt
Hi.
I made a Combobox, and when I make a loop to fill the combobox with items, sometimes it works sometimes not. When it not works, the program just close, without error messages, anything.

Can anyone help me?

I tried the following code:

Combobox* vmCombo = (Combobox*)WMngr->createWindow("AquaLook/Combobox", "VMCombobox");
ListboxTextItem* item;
string Test[4] = {"testA", "testB", "testC", "testD"};
for(int i = 0; i < 4; ++i)
{
item = new ListboxTextItem(Test[i]);
vmCombo->addItem((ListboxItem*) item);
}

Posted: Thu Nov 06, 2008 20:02
by CrazyEddie
Cross-post like you did again, and you'll be banned.

Posted: Fri Nov 07, 2008 09:42
by CrazyEddie
Hi,

I'm not certain as to why this might be happening from the information provided. When the program does not run correctly is the CEGUI.log created? If so, are there any errors in there?

Also, please ensure you correctly catch CEGUI::Exceptions and either deal with them or output the message. Otherwise the program may appear to just close (as you are experiencing).

For example:

Code: Select all

try
{
    // CEGUI code segment
}
catch (CEGUI::Exception &e)
{
    printf("CEGUI Error: %s", e.getMessage().c_str());
}



Aside from this, you will likely have to debug into the program to determine the point of failure and perhaps post again once you have more information.

Having said all this, the issue is highly likely to be related to the use of a cast in the code posted here, and the issue you describe in your other post (which I'll reply to shortly ;) ).

CE.

Posted: Fri Nov 07, 2008 10:38
by leonardoalt
I think the problem is the cast too.
But I used it cuz combobox->addItem does not receives ListboxTextItem, only ListboxItem, right?
(Sorry for making the same question in two different topics)

Posted: Fri Nov 07, 2008 13:07
by CrazyEddie
Replying here as per the other thread for completeness (in case anyone searches in the future)...

While addItem takes a pointer to a ListboxItem, the class ListboxTextItem is a subclass of ListboxItem and so passing its pointer to a function that accepts pointers to the superclass is valid C++ (meaning both should work).

CE.