subscribing events using IrrlichtRender

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

warwick1591
Just popping in
Just popping in
Posts: 3
Joined: Tue Aug 26, 2008 09:48

subscribing events using IrrlichtRender

Postby warwick1591 » Tue Aug 26, 2008 18:14

Hi,

Im using VS9.0 sp1 with CEGUI 0.6.1 and everything compiles and runs fine untill i try to subscribing an event.
I downloaded and am using the precompiled package for vs9.0 of CEGUI.

My code is

Code: Select all

 
PushButton* btn->subscribeEvent(CEGUI::PushButton::EventClicked,
      CEGUI::Event::Subscriber(&GUIManager::handleBtn, this));

Code: Select all

bool GUIManager::handleBtn(const CEGUI::EventArgs &e)
{
   // Do something
   return true;
}


The button animates when i click on it and everything but just cant subscribe an event without it getting this error

Unhandled exception at 0x006ecd84 in GUI.exe: 0xC0000005: Access violation reading location 0x00000004.

Any help would be much appreciated!

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Re: subscribing events using IrrlichtRender

Postby daves » Tue Aug 26, 2008 23:12

warwick1591 wrote:Hi,


Code: Select all

 
PushButton* btn->subscribeEvent(CEGUI::PushButton::EventClicked,
      CEGUI::Event::Subscriber(&GUIManager::handleBtn, this));

!


This code looks a bit funny. How are you setting btn? Does the exception occur within your handler or at the time that you subscribe?

warwick1591
Just popping in
Just popping in
Posts: 3
Joined: Tue Aug 26, 2008 09:48

Postby warwick1591 » Wed Aug 27, 2008 02:34

It must be that line because as soon as it wants to run that line it crashes. It doesnt even get to my handler.
This is my layout of the gui

Code: Select all

Window* root = WindowManager::getSingleton().createWindow("DefaultWindow", "root");
   System::getSingleton().setGUISheet(root);

FrameWindow* frameWindow = (FrameWindow*)WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "testFrame");
   root->addChildWindow(frameWindow);

   frameWindow->setPosition(UVector2(UDim(0.25f, 0), UDim(0.25f, 0)));
   frameWindow->setSize(UVector2(UDim(0.5f, 0), UDim(0.5f, 0)));
   frameWindow->setText("Frame Window");

PushButton* btn = (PushButton*)WindowManager::getSingleton().createWindow("TaharezLook/Button", "testButton");
   root->addChildWindow(btn);

   btn->setPosition(UVector2(UDim(0.25f, 0), UDim(0.25f, 0)));
   btn->setSize(UVector2(UDim(0.1f, 0.1f), UDim(0.1f, 0.1f)));
   btn->setText("Button");


I also tried to add an event to the button rather than subscribing one with

Code: Select all

btn->addEvent(CEGUI::PushButton::EventClicked);

And i get the same thing so im thinking it has something to do with the "CEGUI::PushButton::EventClicked" part.

Thanks for your reply by the way.

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Wed Aug 27, 2008 12:26

You should not have to add an event.

Unless I'm missing something your code looks OK.

I'm trying to understand if there is a chance that there is a mismatch between compile-time and run-time cegui libraries. What rendering system are you using? Rendering systems such as Ogre come with pre-compiled cegui binaries and if you aren't careful then you can create such a "mismatch".

Suggestion: step into your code and see if it is at the point of subscription (that very line) when the crash occurs... let us know.

another suggestion: this should not matter, but i'd like to see if it changes the nature of the crash.. make the btn a child of the framewindow instead of the root gui sheet, and tell us what happens

Lastly: Try to cast your gui sheet to a defaultwindow (instead of just a window)

Code: Select all

Window* root = WindowManager::getSingleton().createWindow("DefaultWindow", "root");
   System::getSingleton().setGUISheet(root);

becomes

Code: Select all

DefauiltWindow* root = ...


Return to “Help”

Who is online

Users browsing this forum: No registered users and 42 guests