Page 1 of 1

[SOLVED] Crash when initializing CEGUI/Ogre

Posted: Thu Oct 29, 2009 11:48
by Stefan Lundmark
I'm getting a crash inside CEGUI 0.7.1 when initializing it with my Ogre RenderWindow.

Code: Select all

   CEGUI::OgreRenderer &renderer = CEGUI::OgreRenderer::bootstrapSystem (*mRenderWindow);
   CEGUI::System::create (renderer);


The RenderWindow passed is correct as the game works correctly without CEGUI. This is the assertion error:

Assertion Failed!

Expression: !ms_Singleton


System::create () creates the System Object but inside its constructor it dies.

_wassert(const wchar_t * expr=0x010fb3ec, const wchar_t * filename=0x01328ad0, unsigned int lineno=73) Line 335 C
CEGUI::Singleton<CEGUI::System>::Singleton<CEGUI::System>() Line 73 + 0x1a bytes C++
> CEGUI::System::System(CEGUI::Renderer & renderer={...}, CEGUI::ResourceProvider * resourceProvider=0x00000000, CEGUI::XMLParser * xmlParser=0x00000000, CEGUI::ImageCodec * imageCodec=0x00000000, CEGUI::ScriptModule * scriptModule=0x00000000, const CEGUI::String & configFile={...}, const CEGUI::String & logFile={...}) Line 229 + 0x54 bytes C++
CEGUI::System::create(CEGUI::Renderer & renderer={...}, CEGUI::ResourceProvider * resourceProvider=0x00000000, CEGUI::XMLParser * xmlParser=0x00000000, CEGUI::ImageCodec * imageCodec=0x00000000, CEGUI::ScriptModule * scriptModule=0x00000000, const CEGUI::String & configFile={...}, const CEGUI::String & logFile={...}) Line 1823 + 0x4a bytes C++


Running a debug build, statically linked. Log says nothing.

Re: Crash (with nothing in the log) when initializing CEGUI/Ogre

Posted: Thu Oct 29, 2009 12:01
by Van

Code: Select all

   CEGUI::System::create (renderer);


Eliminate the above statement from your code. You don't need to do it if you are using bootstrap(). You are trying to instantiate a second instance of CEGUI::System which is not permitted. bootstrap() initializes everything you need.

Re: Crash (with nothing in the log) when initializing CEGUI/Ogre

Posted: Thu Oct 29, 2009 12:05
by Stefan Lundmark
Just found out that the System object is created inside the bootstrap function.

In any case, making it clearer that the System object already has been created wouldn't hurt?

Edit: Thanks Van for confirming!

Re: [SOLVED] Crash when initializing CEGUI/Ogre

Posted: Thu Oct 29, 2009 12:10
by Van
Hence:

Assertion Failed!

Expression: !ms_Singleton


Singleton meaning "single instance". When the class was instantiated the ms_Singleton pointer was set. If you try to instantiate another class instance it checks the ms_Singleton pointer and throws the assertion error if it's already been set (i.e. an instance of the class already exists).

Edit: No problem! :wink: Good luck!