[SOLVED] A widget update question

Rscorpiox

02-07-2009 05:03:38

Hi , I am trying to update some widget by load some infortmation using self define function.

But the program crash every time when I set some attribute of the widget I want to update.

For example , here's my code:

class MyOwnGUI : public Ogre::FrameListener, public OIS::MouseListener
{
public:
MyOwnGUI()
{
enemyInfo = mGUI->createWidget<MyGUI::Progress>("Progress", 200 , 0 , 300, 22, MyGUI::ALIGN_TOP ,"Main");
enemyInfo->setEnabled(true);
enemyInfo->setProgressRange(100);
enemyInfo->setProgressPosition(100);

button = mGUI->createWidget<MyGUI::Button>("Button", 10,10, 300, 80, MyGUI::Align::Bottom, "Main");
button->eventMouseButtonClick = MyGUI::delegates::newDelegate(this,&MyOwnGUI::exit);
}
void updateInfo(Monster *m)
{
enemyInfo->setProgressPosition(m->getHP());
}

void MyOwnGUI::exit(MyGUI::WidgetPtr _widget)
{
button->hide();
}

private:
MyGUI::ProgressPtr enemyInfo;
MyGUI::ButtonPtr button;
};


Also , I tried to update the "enemyInfo" in exit function, and won't be crash .

So I am thinking maybe it's happened because I did't register the function , or losing something like widget as the parameter with the function...?

If it doen , can you guys teach me how to do that?

Don't know how to set/register the widget update function by some self define parameter like the example above ( Monster *m ).

Stuck for more than one day , maybe it's a newbie question.

But I really don't know how to figure it out.

Plz give me some advice. Thx for reading.

my.name

02-07-2009 08:18:50

show log

Rscorpiox

02-07-2009 14:02:28

Thx for reply .

↓Here's MyGUI.log↓


----------------------------------------------------------------------------------------------------------------------------------
loging report for : 07/02/2009 21:12:43
----------------------------------------------------------------------------------------------------------------------------------

21:12:43 | General | Info | * Initialise: Gui | .\src\MyGUI_Gui.cpp | 54
21:12:43 | General | Info | * MyGUI version 2.2.2 | .\src\MyGUI_Gui.cpp | 58
21:12:43 | General | Info | Viewport : 800 600 | .\src\MyGUI_Gui.cpp | 68
21:12:43 | General | Info | * Initialise: ResourceManager | .\src\MyGUI_ResourceManager.cpp | 41
21:12:43 | General | Info | ResourceManager successfully initialized | .\src\MyGUI_ResourceManager.cpp | 53
21:12:43 | General | Info | * Initialise: LayerManager | .\src\MyGUI_LayerManager.cpp | 41
21:12:43 | General | Info | LayerManager successfully initialized | .\src\MyGUI_LayerManager.cpp | 73
21:12:43 | General | Info | * Initialise: WidgetManager | .\src\MyGUI_WidgetManager.cpp | 62
21:12:43 | General | Info | * Register widget factory 'Widget' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Button' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Window' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'List' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'HScroll' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'VScroll' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Edit' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'ComboBox' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'StaticText' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Tab' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'TabItem' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'TabItem' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Sheet' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Progress' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'ItemBox' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'MultiList' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'StaticImage' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Message' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'RenderBox' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'MenuCtrl' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'MenuItem' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'PopupMenu' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'MenuBar' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'ScrollView' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'DDContainer' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | * Register widget factory 'Canvas' | .\src\MyGUI_WidgetManager.cpp | 118
21:12:43 | General | Info | WidgetManager successfully initialized | .\src\MyGUI_WidgetManager.cpp | 93
21:12:43 | General | Info | * Initialise: InputManager | .\src\MyGUI_InputManager.cpp | 51
21:12:43 | General | Info | InputManager successfully initialized | .\src\MyGUI_InputManager.cpp | 74
21:12:43 | General | Info | * Initialise: SubWidgetManager | .\src\MyGUI_SubWidgetManager.cpp | 33
21:12:43 | General | Info | SubWidgetManager successfully initialized | .\src\MyGUI_SubWidgetManager.cpp | 49
21:12:43 | General | Info | * Initialise: SkinManager | .\src\MyGUI_SkinManager.cpp | 40
21:12:43 | General | Info | SkinManager successfully initialized | .\src\MyGUI_SkinManager.cpp | 46
21:12:43 | General | Info | * Initialise: FontManager | .\src\MyGUI_FontManager.cpp | 43
21:12:43 | General | Info | FontManager successfully initialized | .\src\MyGUI_FontManager.cpp | 47
21:12:43 | General | Info | * Initialise: ControllerManager | .\src\MyGUI_ControllerManager.cpp | 36
21:12:43 | General | Info | ControllerManager successfully initialized | .\src\MyGUI_ControllerManager.cpp | 40
21:12:43 | General | Info | * Initialise: PointerManager | .\src\MyGUI_PointerManager.cpp | 41
21:12:43 | General | Info | PointerManager successfully initialized | .\src\MyGUI_PointerManager.cpp | 50
21:12:43 | General | Info | * Initialise: ClipboardManager | .\src\MyGUI_ClipboardManager.cpp | 35
21:12:43 | General | Info | ClipboardManager successfully initialized | .\src\MyGUI_ClipboardManager.cpp | 44
21:12:43 | General | Info | * Initialise: LayoutManager | .\src\MyGUI_LayoutManager.cpp | 41
21:12:43 | General | Info | LayoutManager successfully initialized | .\src\MyGUI_LayoutManager.cpp | 47
21:12:43 | General | Info | * Initialise: DynLibManager | .\src\MyGUI_DynLibManager.cpp | 34
21:12:43 | General | Info | DynLibManager successfully initialized | .\src\MyGUI_DynLibManager.cpp | 36
21:12:43 | General | Info | * Initialise: PluginManager | .\src\MyGUI_PluginManager.cpp | 36
21:12:43 | General | Info | PluginManager successfully initialized | .\src\MyGUI_PluginManager.cpp | 40
21:12:43 | General | Info | * Initialise: LanguageManager | .\src\MyGUI_LanguageManager.cpp | 37
21:12:43 | General | Info | LanguageManager successfully initialized | .\src\MyGUI_LanguageManager.cpp | 44
21:12:43 | General | Info | Load ini file 'core_keyboard.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_language.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_layer.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_font.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_theme.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_resource.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:43 | General | Info | Load ini file 'core_skin.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:44 | General | Info | Load ini file 'core_pointer.xml' from resource group : General | .\src\MyGUI_ResourceManager.cpp | 171
21:12:44 | General | Info | Gui successfully initialized | .\src\MyGUI_Gui.cpp | 112
21:12:44 | General | Info | Font 'Default' using texture size 1024 x 128 | .\src\MyGUI_Font.cpp | 205
21:12:44 | General | Info | Font 'Default' using real height 17 pixels | .\src\MyGUI_Font.cpp | 206



Still . I try to update the ProgressBar at last and crash.

But log seems no record that?

Rscorpiox

10-07-2009 08:43:26

Can anyone give some advice 0.0??

Or some other ways to update widget in self define function with own parameter

Any help ~~ ?

Altren

10-07-2009 13:14:47

All your code looks correct. Check that you use correct input parameters (for example check that Monster *m is not null). Also debug your program and find where you have crash.

Rscorpiox

11-07-2009 06:01:54

I found it !!!

Sorry , I am a idlot >"<

I just check the Monster *m is not null , and create the receive GUI function at the monster class.

But forget to call the receiveGUI function to initial the gui at monster class.

So all the widget are null at the class.

At first I think it's because my function's parameter cause the crash.

But turns our is modified the null widget cause the crash.

Sorry :oops:

And thanks Altren , and my.name ^^.