Assertion error when the CEGUI::System object is destroyed

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

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Assertion error when the CEGUI::System object is destroyed

Postby DaCracker » Mon Jul 03, 2006 14:50

Hi all!
I've decided to use CEGUI (v0.5 RC1) as GUI renderer
for my new game engine. I wrote a small GuiManager
for my engine and CEGUI works perfectly with the
rest of the Engine, except one thing. When I get an
assertion error when I try to delete the CEGUI::System
object...

Here is my code:

Code: Select all

File: GuiManager.h

#ifndef GuiManager_h
#define GuiManager_h

#include "Common.h"

namespace Zephyr
{
   class ZephyrExport GuiManager
   {
   protected:

      static GuiManager *mGuiMgr;
   public:
      //Klassens konstruerare
      GuiManager();
      //Klassens destruerare
      ~GuiManager();

      //Metod för att initiera GuiManagern
      void initialize();

      //Låter dig välja ett GUI-schema
      void setScheme(const CEGUI::String scheme = "TaharezLookSkin.scheme");

      //Låter dig välja en Font
      void setFont(const CEGUI::String font = "Iconified-12.font");

      //Låter dig välja en standardmuspekarikon
      void setDefaultMouseCursor(const CEGUI::String imageSet = "TaharezLook", const CEGUI::String imageName = "MouseArrow");

      void loadLayout(const CEGUI::String name);

      //Skapar en GUI-ruta
      void createGuiWindow(const CEGUI::String type = "DefaultGUISheet", const CEGUI::String name = "RootWindow");

      void showMouseCursor(bool show);

      CEGUI::Renderer* getCEGUIRenderer();

      static GuiManager* getSingletonPtr();
   protected:
   };
}

#endif



Code: Select all

File: GuiManager.cpp

#include "GuiManager.h"
#include "Global.h"

namespace Zephyr
{
   GuiManager* GuiManager::mGuiMgr;

   GuiManager::GuiManager()
   {
      global->mGuiRenderer = 0;
      global->mGuiSystem = 0;
      global->mGuiWindow = 0;
   }

   GuiManager::~GuiManager()
   {
      if(global->mGuiSystem)
      {
         delete global->mGuiSystem;
         global->mGuiSystem = 0;
      }

      if(global->mGuiRenderer)
      {
         delete global->mGuiRenderer;
         global->mGuiRenderer = 0;
      }

      delete CEGUI::System::getSingletonPtr();

      Ogre::LogManager::getSingleton().logMessage("Zephyr 2 SubSystem: CEGUI unloaded... ");
   }
   void GuiManager::initialize()
   {
      //CEGUI
      //Den här koden initierar vår GUI-motor
      global->mGuiRenderer = new CEGUI::OgreCEGUIRenderer(global->mWindow,Ogre::RENDER_QUEUE_OVERLAY, false, 0, global->mSceneMgr);
      global->mGuiSystem = new CEGUI::System(global->mGuiRenderer);
      //new CEGUI::System(global->mGuiRenderer);

      global->mGuiWindowMgr = &CEGUI::WindowManager::getSingleton();

      CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Insane);

      Ogre::LogManager::getSingleton().logMessage("Zephyr2 SubSystem: CEGUI initialized... ");
   }

   void GuiManager::setScheme(const CEGUI::String scheme)
   {
      //Laddar ett schema för spelets GUI
      CEGUI::SchemeManager::getSingleton().loadScheme(scheme);
   }

   void GuiManager::loadLayout(const CEGUI::String name)
   {
   
   }

   void GuiManager::setDefaultMouseCursor(const CEGUI::String imageSet, const CEGUI::String imageName)
   {
      //Väljer en standardmuspekare
      //global->mGuiSystem->setDefaultMouseCursor(imageSet,imageName);
      CEGUI::System::getSingleton().setDefaultMouseCursor(imageSet,imageName);
   }

   void GuiManager::setFont(const CEGUI::String font)
   {
      //Skapar en font från en fil
      CEGUI::FontManager::getSingleton().createFont(font);
      //global->mGuiSystem->setDefaultFont((CEGUI::utf8*)font.c_str());
   }

   void GuiManager::createGuiWindow(const CEGUI::String type, const CEGUI::String name)
   {
      //Skapar en gui-ruta
      //global->mGuiWindow = global->mGuiWindowMgr->createWindow(type,name);
      global->mGuiWindow = global->mGuiWindowMgr->loadWindowLayout((CEGUI::utf8*)"Zephyr2MainLayout.layout");
      //global->mGuiSystem->setGUISheet(global->mGuiWindow);
      CEGUI::System::getSingletonPtr()->setGUISheet(global->mGuiWindow);
   }

   CEGUI::Renderer* GuiManager::getCEGUIRenderer()
   {
      return global->mGuiRenderer;
   }

   void GuiManager::showMouseCursor(bool show)
   {
      if(show)
      {
         CEGUI::MouseCursor::getSingleton().show();
      }
      else
      {
         CEGUI::MouseCursor::getSingleton().hide();
      }
   }

   GuiManager* GuiManager::getSingletonPtr()
   {
      if(!mGuiMgr)
      {
         mGuiMgr = new GuiManager();
      }

      return mGuiMgr;
   }
}


any ideas on what could be wrong?

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Tue Jul 04, 2006 10:08

What is the line that fails assertion?

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Postby DaCracker » Tue Jul 04, 2006 16:38

The assertion error:

Program:...
File: dbgdel.cpp
Line: 52

Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Wed Jul 05, 2006 00:00

Im getting the same crash. Im using OGRE, and so far it only happens when I create a font. If I dont specify a font, the system shuts down cleanly.

Ive traced the crash to the following method: "void FontManager::destroyFont(const String& name)" in ceguifontmanager.cpp, at the actual deletion call i.e.

Code: Select all

delete pos->second;


Im creating the font like this:

Code: Select all

CEGUI::FontManager::getSingleton().createFont("Omicz.font");


Where my font xml definition is defined as:

Code: Select all

<?xml version="1.0" ?>
<Font Name="Omicz" Filename="OMICZ___.TTF" Type="FreeType" Size="12" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true"/>


The log reports that the font was created successfully. Thats all Ive got so far, hope it helps.

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Postby DaCracker » Wed Jul 05, 2006 08:37

is this a bug in the code then? anyway, I think that
I will check it out and see if there is anything to
do about it...
thanks alot for your help!

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Wed Jul 05, 2006 18:07

DaCracker, could you do us a favour and comment out your font creation and see if the crash still persists in your code too?

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Wed Jul 05, 2006 21:51

Hmm Im not having much joy with fonts. Im getting the same crash again, related to fonts but with something else.

Whats strange about it though, is that what Im doing here is being performed fine in the Sample_FontDemo Sample (so what am I doing wrong?) Here Im trying to modify the font size:

Code: Select all

Font *f = CEGUI::FontManager::getSingleton().getFont("myFont");
f->setProperty ("PointSize", PropertyHelper::intToString (int (22)));


But when I do this in my app, I get that nasty " _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)" crash.

Here is the call stack:

Code: Select all

CEGUIBase_d.dll!CEGUI::RawDataContainer::release()  Line 40   C++
CEGUIBase_d.dll!CEGUI::FreeTypeFont::free()  Line 376   C++
CEGUIBase_d.dll!CEGUI::FreeTypeFont::updateFont()  Line 388   C++
CEGUIBase_d.dll!CEGUI::FontProperties::FreeTypePointSize::set(CEGUI::PropertyReceiver * receiver=0x0428aff8, const CEGUI::String & value={...})  Line 176 + 0xf bytes   C++
CEGUIBase_d.dll!CEGUI::PropertySet::setProperty(const CEGUI::String & name={...}, const CEGUI::String & value={...})  Line 127 + 0x31 bytes   C++


Does my font definition (a few posts above) look okay?

Should I raise a bug in Mantis?

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Wed Jul 05, 2006 22:28

Could you possible try out this patch and see if it fixes the problem?
http://www.cegui.org.uk/mantis/view.php?id=60

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Wed Jul 05, 2006 23:45

Yup, I'll try it now and let you know in this post.


** EDIT **

Works great :D

No more crashes on either count. Nice work nightwolf and zap.

** EDIT **
Last edited by spannerman on Sun Jul 09, 2006 17:12, edited 1 time in total.

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Postby DaCracker » Fri Jul 07, 2006 11:12

How do I update the 0.5 RC1 source with that
patch provided above? how do I use this
.diff file under Windows/Cygwin?

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Fri Jul 07, 2006 12:03

Sorry man, I forget how to apply patches, but I have done it once before. Try a search here or on the Ogre forums, I think I asked about this specific thing ages ago.

This patch was small enough for me to go through manually. Just add the lines of code specified by a plus (+) and remove the lines of code marked with a subtract symbol (-).

Mantis hasnt been updated for this isuse, maybe one of the devs could comment on the status of this patch?

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Postby DaCracker » Fri Jul 07, 2006 14:04

Okey man, no problem, I'll check the Ogre forums :)

User avatar
DaCracker
Just popping in
Just popping in
Posts: 8
Joined: Sat Jun 04, 2005 17:12
Contact:

Postby DaCracker » Fri Jul 07, 2006 14:41

I've successfully added the patch now, and my game engine
can finally use this splendid GUI system again! :) thanks
alot for all your help! :D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 19 guests