Page 1 of 1

SubscribeEvent Errors

Posted: Fri May 06, 2005 20:49
by charmy
Greetings,

Having a small issue with subscribing events to an edit box, sadly there is no error output, its a memeory access error, however when I run the debugger the line it crashes on is the following.


Code: Select all

wMgr.getWindow("Input")->subscribeEvent(Editbox::EventTextAccepted,CEGUI::Event::Subscriber(&slGuiManager::handleInput, this));


I thought the format was correct but for some reason its causing a crash.
If i comment this line the program loads fine.


Here is a snippit of the surrounding code.

Code: Select all

   //WindowManager& wMgr = WindowManager::getSingleton();
    Editbox* ebox = (Editbox*)wMgr.createWindow("TaharezLook/Editbox","Input");
   console->addChildWindow(ebox);
   ebox->setPosition(Point(.05, .81));
   ebox->setSize(Size(.9, .19));
wMgr.getWindow("Input")->subscribeEvent(CEGUI::Editbox::EventTextAccepted,CEGUI::Event::Subscriber(&slGuiManager::handleInput, this));


The commented line is to show that i have infact set the reference of wMgr to the manager singleton earlier on.

And finally the event handler code.

Code: Select all

bool slGuiManager::handleInput(const CEGUI::EventArgs& e)
{
   return true;
}

yup it does alot ;)

Anyway this has be quite baffled and i am hoping someone can point me in the right direction with this one.

I appricate any help you can offer =).

Thanks Much.

Re: SubscribeEvent Errors

Posted: Fri May 06, 2005 23:29
by lindquist
try this instead:

Code: Select all

ebox->subscribeEvent(CEGUI::Editbox::EventTextAccepted,CEGUI::Event::Subscriber(handleInput, this));


you don't need to take the address of the handler function, and no need to use the window manager when you already have a pointer to the editbox.

Re: SubscribeEvent Errors

Posted: Sat May 07, 2005 04:23
by charmy
Thanks for the response, however the same thing seems to be happeneing with that line of code.

I will continue to play around with it, but if anyone has any ideas why this might be, please let me know.

Thanks again =)

BTW i am using stlport 4.6.2 and this is with the ogre renderer.

Re: SubscribeEvent Errors

Posted: Sat May 07, 2005 12:52
by lindquist
hmm..
could you post your call stack ?

preferably in a code section

Re: SubscribeEvent Errors

Posted: Sat May 07, 2005 22:55
by charmy
Surely, Here it is

Code: Select all

>   Demo_SkeletalAnimation.exe!CEGUI::slGuiManager::DebugConsole()  Line 88 + 0x31   C++
    Demo_SkeletalAnimation.exe!SkeletalApplication::createScene()  Line 249   C++
    Demo_SkeletalAnimation.exe!ExampleApplication::setup()  Line 95 + 0xd   C++
    Demo_SkeletalAnimation.exe!ExampleApplication::go()  Line 55 + 0xd   C++
    Demo_SkeletalAnimation.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, char * strCmdLine=0x00141f31, HINSTANCE__ * __formal=0x00000000)  Line 36 + 0x8   C++
    Demo_SkeletalAnimation.exe!WinMainCRTStartup()  Line 390 + 0x39   C
    kernel32.dll!7c816d4f()    
    kernel32.dll!7c8399f3()    


I will post the source in a few mins, its just a mod on the demo skeletal app. Don't know why i didn't just do that in the first place....

Re: SubscribeEvent Errors

Posted: Sat May 07, 2005 22:58
by charmy
Here is the Source for the program, thanks again for all the help =)

Re: SubscribeEvent Errors

Posted: Sat May 07, 2005 23:55
by charmy
Hmm Just found out that its only in the debug mode, it happens with the ogre GUI demo as well, so my libs must be corrupt or some such thing, Please if you would though test this source on your machine in debug mode to see if it gives you any problems.


Thank you again.


EDIT: Well it runs atleast until i try to excute the command, I have a feeling that the libs provided in the ogre package are corrupt in some way becuase i do not have these issues when i use the NeL Renderer.

Has anyone else had problems with edit boxes in the ogre renderer?

Re: SubscribeEvent Errors

Posted: Mon May 09, 2005 16:19
by charmy
Anyone had a chance to test this yet??? I am still having the same issue.

Re: SubscribeEvent Errors

Posted: Sat Jun 24, 2006 07:27
by billconan
charmy wrote:Anyone had a chance to test this yet??? I am still having the same issue.


are you using vs2005?

Posted: Fri Jul 07, 2006 00:07
by enkd
I wrote this response for another thread, but I'm almost sure this is your problem... took me a couple of days to debug.

Make sure that you built CEGUI against the same version of STL or STLport that your application uses. I had the same problem, access violation calling subscribeEvent.

My problem was that I built CEGUI against STL, and my application used STLport. As such, any CEGUI class which used standard library data members would be corrupted upon returing from CEGUI calls. For example, all was fine inside WindowManager::createWindow, but back in MY code, the Window was corrupted. This caused an invalid __vfptr (virtual function table pointer) and an access violation on the subscribeEvent call.

An easy check for this is to evaluate sizeof(CEGUI::EventSet) in the debugger, both when inside a CEGUI call and in your own code. The numbers shoud match. If not:

check your includes and rebuild CEGUI with STLport (if you use it)
also, be sure to include the preprocessor directive _STLP_DEBUG if you are using a debug build.