diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 63406cb867..8007207aa0 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -18,6 +18,7 @@ #include "model/doc/document.hpp" #include "model/world/data.hpp" +#include "view/render/overlaysystem.hpp" CS::Editor::Editor (OgreInit::OgreInit& ogreInit) : mUserSettings (mCfgMgr), mDocumentManager (mCfgMgr), mViewManager (mDocumentManager), @@ -65,6 +66,11 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) this, SLOT (createNewGame (const boost::filesystem::path&))); } +CS::Editor::~Editor () +{ + CSVRender::OverlaySystem::instance().destroy(); // destruct before Ogre::Root +} + void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs) { for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter) diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index c87e24e77a..88479f68c3 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -64,6 +64,7 @@ namespace CS public: Editor (OgreInit::OgreInit& ogreInit); + ~Editor (); bool makeIPCServer(); void connectToIPCServer(); diff --git a/apps/opencs/view/render/overlaysystem.hpp b/apps/opencs/view/render/overlaysystem.hpp index 64f95975e7..087d414ff6 100644 --- a/apps/opencs/view/render/overlaysystem.hpp +++ b/apps/opencs/view/render/overlaysystem.hpp @@ -14,7 +14,7 @@ namespace CSVRender } ~OverlaySystem() { - delete mOverlaySystem; + if(mOverlaySystem) delete mOverlaySystem; } OverlaySystem(OverlaySystem const&); @@ -30,6 +30,11 @@ namespace CSVRender Ogre::OverlaySystem *get() { return mOverlaySystem; } + + void destroy() { + delete mOverlaySystem; + mOverlaySystem = NULL; + } }; }