Assertion failed: ms_Singleton

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

sandman1687
Just popping in
Just popping in
Posts: 3
Joined: Thu Jul 10, 2008 21:14

Assertion failed: ms_Singleton

Postby sandman1687 » Thu Jul 10, 2008 21:53

Hello,

I have a project that has been worked on for quite some time (started as thesis, now research proj) which uses H3D and CEGUI.

My program uses CEGUI to display windows, buttons, and test fields over a 3D scene, and it has worked very well in the past.

Last week I decided to update the project from H3D1.5 and CEGUI 0.5 to H3D2.0 and CEGUI 0.6.1 (I also updated MSVC++ from 2005 to 2008). I made all the same revisions to the code as were present in the older code base, and I am now running into the above-mentioned problem.
When my program calls Scene::mainLoop() (which initializes a GLUT window and starts a glutMainLoop()), it crashes with the "Assertion failed" error.

Commenting out "CEGUI::System::getSingleton().renderGUI();", which is called from the H3D render function, does not solve the problem.

When I run a debug version, I get a breakpoint in a custom MouseSensor file which injects mouse events into CEGUI as well as H3D.

Code: Select all

1  void MyzieMouseSensor::mouseButtonAction( int button, int state )
2  {
3     MouseSensor::mouseButtonAction(button, state);
4     switch( button ) {
5        case LEFT_BUTTON:
6           if (state == DOWN)
7              CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
8           else if (state == UP)
9              CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
10          break;
11       case RIGHT_BUTTON:
12          if (state == DOWN)
13             CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
14          else if (state == UP)
15             CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
16          break;
17        case MIDDLE_BUTTON:
18          if (state == DOWN)
19             CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
20          else if (state == UP)
21             CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
22          break;
23    }
24 }
25 void MyzieMouseSensor::mouseWheelAction( int wheel, int direction )
26 {
27    MouseSensor::mouseWheelAction(direction);
28    CEGUI::System::getSingleton().injectMouseWheelChange(direction);
29 }
30 void MyzieMouseSensor::mouseMotionAction( int x, int y )
31 {
32    MouseSensor::mouseMotionAction(x, y);
33    CEGUI::System::getSingleton().injectMousePosition(x, y);
34 }


I consistently get the breakpoint at line 33. I put the variables x and y on watch, and they show the correct (expected) values at the time of execution.

Anyway, I've been banging my head on my keyboard for a few days now because there isn't a single difference between the old code and the new code except for the versions (and in the mouseSensor file, "mouseMotionAction" used to be "GLUTmouseMotionAction", so I changed the method names appropriately).

Any help or suggestions would be greatly appreciated. Thanks.

-sd

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Jul 11, 2008 08:33

Hi, and welcome :)

It might be possible that the first mouse motion event is sent before the GUI system is initialised. Do you setup the glut callbacks before or after the CEGUI systems are setup? If it's not easy or desirable to modify the initialisation order, you could either have a flag to indicate when CEGUI is up and running, or in the callback, use for example, CEGUI::System::getSingletonPtr() instead, and check the result is not 0 before continuing.

Hope it's something simple like this and nothing more difficult to track down :)

CE.

sandman1687
Just popping in
Just popping in
Posts: 3
Joined: Thu Jul 10, 2008 21:14

Postby sandman1687 » Fri Jul 11, 2008 18:48

Looking into the problem, I'm pretty confident that the modified mouse sensor isn't to blame. Commenting out my initialization of the mouse sensor does not get rid of the error.

When I do comment out the initialization however, I get a new breakpoint location, which is incidentally an "xutility internal header"

What I do know though is that the last call that MY code made was CEGUI::System::getSingleton().renderGUI. I put cout calls before and after it to see whether it was to blame, and sure enough, the first cout executes, but the second one does not.

When I change the line to CEGUI::System::getSingletonPtr()->renderGUI(), I no longer get an Assertion failed error, but just a crash that debugging in VC2008 tells me happened at, wait for it, CEGUI::System::getSingletonPtr()->renderGUI() (specifically, the error is "Unhandled exception at 0x00e7b293 in H3DLoad_d.exe: 0xC0000005: Access violation reading location 0x00000038").

I setup the glut window right before I call scene's mainLoop():

Code: Select all

1  GLUTWindow *glwindow = new GLUTWindow;
2  change_nav_type->setOwnerWindow( glwindow );
3  ks->keyPress->route( change_nav_type );
4  glwindow->fullscreen->setValue( fullscreen );
5  glwindow->mirrored->setValue( mirrored );
6  glwindow->renderMode->setValue( render_mode );
7  glwindow->width->setValue(width);
8  glwindow->height->setValue(height);
9  scene->window->push_back( glwindow );
10 scene->sceneRoot->setValue( g.get() );
11 Scene::mainLoop();
12 using namespace CEGUI;
13 CEGUI::OpenGLRenderer* myRenderer = new CEGUI::OpenGLRenderer(0);
14 new CEGUI::System(myRenderer);


Changing the initialization order of the cegui system (putting lines 13 & 14 before 1) results in a cegui genericException in file ceguidynamicmodule.cpp.

Anyway, as I said before, all the code worked perfectly with previous versions of both cegui (0.5.0) and h3d (1.5), so I don't really know where to go from here.

Eddie, thanks for your help, it's much appreciated.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Jul 12, 2008 06:16

Man, how I love these type of issue :lol:

Couple of really obvious points - not intended to insult anyone's intelligence, but still I have to ask:
- Did you remember to get the matching dependencies pack (or rebuild the dependencies) for use with the new compiler.
- Did you remove all traces of the old CEGUI prior to doing the full clean and rebuild of your project?

Ok, now that is out of the way...

I'm really not certain what is going on here, especially since 0.5.0 was working. Did you update the three elements (CEGUI, H3D, and c/c++ compiler) simultaneously, or was it a more gradual transition? If it was a structured transition, at what stage did the issue first arise?

A call-stack at the tine of the assert / break might be useful (though maybe not).

hanging the initialization order of the cegui system (putting lines 13 & 14 before 1) results in a cegui genericException in file ceguidynamicmodule.cpp.

That's quite interesting, though possibly not relevant. This usually means that it can't find the dll module for the XML parser.

CE

sandman1687
Just popping in
Just popping in
Posts: 3
Joined: Thu Jul 10, 2008 21:14

Postby sandman1687 » Mon Jul 14, 2008 21:45

Well, I fixed the singleton issue. It seems that the new version of H3D initializes the windows in a different order than before, and I didn't take it into account.

Thanks for your suggestions and help! Now on to fix H3D errors :P

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jul 15, 2008 08:40

Cool :)

I'm glad it was not our issue :lol:

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 8 guests