[solved] Wiki's GamState Manager + Hikari, crashes

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
marc_
Halfling
Posts: 48
Joined: Wed May 21, 2008 7:03 pm
Location: México, CVA

[solved] Wiki's GamState Manager + Hikari, crashes

Post by marc_ »

hey guys, i have problems changing the state with hikari, i captured some screenshots, first the mouse released event is fired and the mouse button id is injected to the hikari manager
ogre1.JPG
ogre1.JPG (10.58 KiB) Viewed 913 times
then i receive the hikari callback where i process to see if it is time to change the state
ogre2.JPG
ogre2.JPG (3.62 KiB) Viewed 914 times
after calling change state, the statemanager calls the exit method of the current state.
ogre3.JPG
ogre3.JPG (13.46 KiB) Viewed 913 times
after doing that, the game manager calls the second state's enter method where it is initialize the second state, there i have another flash UI, that also gets initialized

after all that ther is no error, and when it gets back to the point of origin which is the mouse released call back
ogre1.JPG
ogre1.JPG (10.58 KiB) Viewed 913 times
and the vc++ 9 express throws an exception
Unhandled exception at 0x003d2c2b in prototipov1.1.exe: 0xC0000005: Access violation reading location 0xbaadf00d.
any ideas of how should i manage hikari in order to stop this?,,, hellP!!
thanks in advice.
Last edited by marc_ on Sat Jan 31, 2009 11:23 am, edited 1 time in total.
marc_
Halfling
Posts: 48
Joined: Wed May 21, 2008 7:03 pm
Location: México, CVA

Re: Wiki's GamState Manager + Hikari, crashes

Post by marc_ »

solved using a flag to let he program finish with all the propagated calls, my bad i know, more details here:

calsmurf2904 wrote:it doesn't look like a hikari problem.
It's more that you keep injecting mouse input while the hikari object is destroyed (in the exit function upon changing state)
link: http://www.ogre3d.org/forums/viewtopic. ... 75#p326408

ajs15822 wrote:@ marc_,

It looks you're destroying Hikari while it's in the middle of propagating callbacks.

Imagine this bit of pseudo-code:

Code: Select all

MyClass::doStuff()
{
     for(i = 0; i < 10; i++)
          doSomething();

     someOtherStuff();
}

void doSomething()
{
     delete MyClass::getPointer();
}
Notice that 'doSomething()' is deleting the class instance that called it? When the flow of control returns from 'doSomething()', MyClass is already destroyed, hence your runtime error.

In the Hikari callback that is initiating the game-state change, instead of switching to a new state directly, I would recommend setting a simple boolean flag that is checked later during your state's update loop.

Or, you could also use my State Manager example from this thread (which supports queued state advancement): http://www.ogre3d.org/forums/viewtopic. ... 37#p317837
link: http://www.ogre3d.org/forums/viewtopic. ... 75#p326411



marc_ wrote:lol i'm so damn stupid, lol ok, i should apologize about my post right?. well i'm sorry for such stupid post.... but you were right i used a flag instead , anyway i feel i should change the framelistener to my own game loop.. thanks AJS, :) by the way do you think if i change back from my new state there will be any problem again?.. well i will keep testing..
:) thanks again
Link: http://www.ogre3d.org/forums/viewtopic. ... 75#p326437









everything posted here:
http://www.ogre3d.org/forums/viewtopic. ... 37#p326382
Post Reply