Am I deleted CEGUI correctly?

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

dredogol
Not too shy to talk
Not too shy to talk
Posts: 41
Joined: Sat Apr 18, 2009 20:43

Am I deleted CEGUI correctly?

Postby dredogol » Sat Jun 20, 2009 17:39

Alright, I'm trying to make a GUI manager for the GameManager system for Ogre3D.
I need you guys to tell me if I'm deleting this stuff in the correct order...

The only happens once, when the GUI is deleted when the game exits.

Code: Select all

GUIManager::~GUIManager()
{
   mp_guiRenderer->clearRenderList();
   mp_guiRenderer->destroyAllTextures();
   mp_guiRenderer->removeAllEvents();
   delete mp_guiRenderer;
   mp_guiSystem->cleanupXMLParser();
   mp_guiSystem->removeAllEvents();
   delete mp_guiSystem;
}


This is how everything is initialized:

Code: Select all

GUIManager::GUIManager()
{
   Ogre::RenderWindow *pOgreRendWin = GameManager::getSingleton()->getOgreRenderWindowPtr();

   mp_guiRenderer = new CEGUI::OgreCEGUIRenderer(
      pOgreRendWin, Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
   mp_guiSystem = new CEGUI::System (mp_guiRenderer);

   CEGUI::SchemeManager::getSingleton().loadScheme(
      (CEGUI::utf8*)"TaharezLook.scheme");
   CEGUI::SchemeManager::getSingleton().loadScheme(
      (CEGUI::utf8*)"VanillaSkin.scheme");
   CEGUI::SchemeManager::getSingleton().loadScheme(
      (CEGUI::utf8*)"WindowsLook.scheme");

   mp_guiSystem->setDefaultMouseCursor ((CEGUI::utf8*)"TaharezLook",
      (CEGUI::utf8*)"MouseArrow");
   CEGUI::MouseCursor::getSingleton().setImage(
      CEGUI::System::getSingleton().getDefaultMouseCursor());

   if (! CEGUI::FontManager::getSingleton().isFontPresent("BlueHighway-12"))
      CEGUI::FontManager::getSingleton().createFont("bluehighway-12.font");
   if (! CEGUI::FontManager::getSingleton().isFontPresent("BlueHighway-10"))
      CEGUI::FontManager::getSingleton().createFont("bluehighway-10.font");
   if (! CEGUI::FontManager::getSingleton().isFontPresent("BlueHighway-8"))
      CEGUI::FontManager::getSingleton().createFont("bluehighway-8.font");
   if (! CEGUI::FontManager::getSingleton().isFontPresent("Commonwealth-10"))
      CEGUI::FontManager::getSingleton().createFont("Commonwealth-10.font");

   delete pOgreRendWin;
}

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

Re: Am I deleted CEGUI correctly?

Postby CrazyEddie » Sun Jun 21, 2009 09:05

This is totally over the top - you're making things too complicated for yourself :)

Basically, CEGUI manages objects for you - this is why we have all those 'create' type functions instead of having you use the C++ new keyword directly, as such - under normal circumstances - the only things you need to cleanup yourself are the CEGUI::System object and the CEGUI::Renderer object (in that order), if you're using custom XMLParsers or script modules then those have to also be cleaned up, but in your case:

Code: Select all

delete mp_guiSystem;
delete mp_guiRenderer;

is all that's needed.

HTH

CE.

dredogol
Not too shy to talk
Not too shy to talk
Posts: 41
Joined: Sat Apr 18, 2009 20:43

Re: Am I deleted CEGUI correctly?

Postby dredogol » Sun Jun 21, 2009 20:53

Ah, thx. =D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 12 guests