Error in ListboxTextItem

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Error in ListboxTextItem

Postby leonardoalt » Thu Nov 06, 2008 18:53

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);
}

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

Postby CrazyEddie » Thu Nov 06, 2008 20:02

Cross-post like you did again, and you'll be banned.

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

Postby CrazyEddie » Fri Nov 07, 2008 09:42

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.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Fri Nov 07, 2008 10:38

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)

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

Postby CrazyEddie » Fri Nov 07, 2008 13:07

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests