MyGUI crashes when drawing widgets

caohuuloc

07-05-2009 11:43:33

When I add so many items to a list, MyGUI always crashes. I think because I add item so fastly. If I add "Sleep(50)" after each time I call "listPtr->addItem", it runs better, but sometimes it still crashes.
Please help me! Anyone knows about this problem?

CHICK3NPROIT

08-05-2009 04:07:40

Anyone know about this problem? Please help for him. :(

jacmoe

08-05-2009 04:22:51

Give us some code to look at.
Or at least some more information.

caohuuloc

08-05-2009 08:42:20

I am sorry. The root cause is not because of updating GUI too fastly.
My problem is: I am trying to update GUI from another thread. MyGUI often cashes when I use another thread to update GUI. Anybody have experience with this problem? Please help me!!!

compvis

08-05-2009 10:57:46

Luồng khác ở đây là gì ? Bạn có thể đưa một số code lên không ? Như thế sẽ tốt hơn, để mọi người cùng giải quyết...

caohuuloc

11-05-2009 05:10:03

Here is the example code:

void ThreadList(void *param)
{
MyGUI::ListPtr lst = (MyGUI::ListPtr)param;
bool add = true;
while (1)
{
Sleep(1000);
if (add)
{
char buff[100];
for (int i = 1; i <= 50; i++)
{
sprintf(buff, "Item %d", i);
lst->addItem(buff);
//Sleep(50); //Uncomment this line, it works better but somtimes still crashes
}
}
else
{
lst->removeAllItems();
}
add = !add;
}
}

void DemoKeeper::createScene()
{
MyGUI::ListPtr lst = mGUI->createWidget<MyGUI::List>("List", 50, 50, 300, 500, MyGUI::Align::Default, "Main");
HANDLE h = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadList, lst, 0, NULL);
}

CHICK3NPROIT

14-05-2009 07:16:48

I have also the same bugs.

When we set list item into thread, we will be crashed. I think the reason is 2 thread: Main thread to draw when we call addItem of ListPtr and My thread.

Anyone know about this problem? Please helppppppppppp. Thank you very much.

my.name

16-05-2009 14:01:22

use mutex

caohuuloc

16-05-2009 18:59:51

Where to enter and leave mutex?