From 8a05c0e5c080c16026c9fe8503a9050cce54efca Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 17 Oct 2014 14:23:27 +0200 Subject: [PATCH] fixed overlay singleton --- apps/opencs/editor.cpp | 9 +++++---- apps/opencs/editor.hpp | 2 +- apps/opencs/view/render/overlaysystem.cpp | 16 +++++----------- apps/opencs/view/render/overlaysystem.hpp | 1 - 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index ba1cbb8fa..982fc20d5 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -20,7 +20,8 @@ #include "model/world/data.hpp" CS::Editor::Editor (OgreInit::OgreInit& ogreInit) -: mUserSettings (mCfgMgr), mDocumentManager (mCfgMgr), mViewManager (mDocumentManager), +: mUserSettings (mCfgMgr), mOverlaySystem (0), mDocumentManager (mCfgMgr), + mViewManager (mDocumentManager), mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL) { std::pair > config = readConfig(); @@ -32,6 +33,8 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); + mOverlaySystem.reset (new CSVRender::OverlaySystem); + Bsa::registerResources (Files::Collections (config.first, !mFsStrict), config.second, true, mFsStrict); @@ -66,9 +69,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) } CS::Editor::~Editor () -{ - CSVRender::OverlaySystem::instance().destroy(); // destruct before Ogre::Root -} +{} void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs) { diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index f252748c4..cd39d53a4 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -43,7 +43,7 @@ namespace CS Nif::Cache mNifCache; Files::ConfigurationManager mCfgMgr; CSMSettings::UserSettings mUserSettings; - CSVRender::OverlaySystem mOverlaySystem; + std::auto_ptr mOverlaySystem; CSMDoc::DocumentManager mDocumentManager; CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; diff --git a/apps/opencs/view/render/overlaysystem.cpp b/apps/opencs/view/render/overlaysystem.cpp index d72fd35ed..f565f5af0 100644 --- a/apps/opencs/view/render/overlaysystem.cpp +++ b/apps/opencs/view/render/overlaysystem.cpp @@ -1,21 +1,23 @@ #include "overlaysystem.hpp" +#include + #include namespace CSVRender { OverlaySystem *OverlaySystem::mOverlaySystemInstance = 0; - OverlaySystem::OverlaySystem() : mOverlaySystem(NULL) + OverlaySystem::OverlaySystem() { assert(!mOverlaySystemInstance); mOverlaySystemInstance = this; + mOverlaySystem = new Ogre::OverlaySystem(); } OverlaySystem::~OverlaySystem() { - if(mOverlaySystem) - delete mOverlaySystem; + delete mOverlaySystem; } OverlaySystem &OverlaySystem::instance() @@ -26,15 +28,7 @@ namespace CSVRender Ogre::OverlaySystem *OverlaySystem::get() { - if(!mOverlaySystem) - mOverlaySystem = new Ogre::OverlaySystem(); return mOverlaySystem; } - - void OverlaySystem::destroy() - { - delete mOverlaySystem; - mOverlaySystem = NULL; - } } diff --git a/apps/opencs/view/render/overlaysystem.hpp b/apps/opencs/view/render/overlaysystem.hpp index c9bc533c1..f8a78f329 100644 --- a/apps/opencs/view/render/overlaysystem.hpp +++ b/apps/opencs/view/render/overlaysystem.hpp @@ -20,7 +20,6 @@ namespace CSVRender static OverlaySystem &instance(); Ogre::OverlaySystem *get(); - void destroy(); }; }