Changeset 8423 for code/trunk/src/libraries/core/Core.cc
- Timestamp:
- May 9, 2011, 5:06:49 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/Core.cc
r8366 r8423 90 90 91 91 Core::Core(const std::string& cmdLine) 92 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands) 93 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 94 // Cleanup guard for external console commands that don't belong to an Identifier 95 , consoleCommandDestroyer_(ConsoleCommand::destroyAll) 92 : pathConfig_(NULL) 93 , dynLibManager_(NULL) 94 , signalHandler_(NULL) 95 , configFileManager_(NULL) 96 , languageInstance_(NULL) 97 , ioConsole_(NULL) 98 , tclBind_(NULL) 99 , tclThreadManager_(NULL) 100 , rootScope_(NULL) 101 , graphicsManager_(NULL) 102 , inputManager_(NULL) 103 , guiManager_(NULL) 104 , graphicsScope_(NULL) 96 105 , bGraphicsLoaded_(false) 97 106 , bStartIOConsole_(true) … … 99 108 , ogreConfigTimestamp_(0) 100 109 , bDevMode_(false) 110 , destructionHelper_(this) 101 111 { 102 112 // Set the hard coded fixed paths 103 this->pathConfig_ .reset(new PathConfig());113 this->pathConfig_ = new PathConfig(); 104 114 105 115 // Create a new dynamic library manager 106 this->dynLibManager_ .reset(new DynLibManager());116 this->dynLibManager_ = new DynLibManager(); 107 117 108 118 // Load modules … … 128 138 // create a signal handler (only active for Linux) 129 139 // This call is placed as soon as possible, but after the directories are set 130 this->signalHandler_ .reset(new SignalHandler());140 this->signalHandler_ = new SignalHandler(); 131 141 this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log"); 132 142 … … 147 157 148 158 // Manage ini files and set the default settings file (usually orxonox.ini) 149 this->configFileManager_ .reset(new ConfigFileManager());159 this->configFileManager_ = new ConfigFileManager(); 150 160 this->configFileManager_->setFilename(ConfigFileType::Settings, 151 161 CommandLineParser::getValue("settingsFile").getString()); 152 162 153 163 // Required as well for the config values 154 this->languageInstance_ .reset(new Language());164 this->languageInstance_ = new Language(); 155 165 156 166 // Do this soon after the ConfigFileManager has been created to open up the 157 167 // possibility to configure everything below here 158 ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);168 RegisterRootObject(Core); 159 169 this->setConfigValues(); 160 170 … … 166 176 } 167 177 if (this->bStartIOConsole_) 168 this->ioConsole_ .reset(new IOConsole());178 this->ioConsole_ = new IOConsole(); 169 179 #endif 170 180 … … 173 183 174 184 // Load OGRE excluding the renderer and the render window 175 this->graphicsManager_ .reset(new GraphicsManager(false));185 this->graphicsManager_ = new GraphicsManager(false); 176 186 177 187 // initialise Tcl 178 this->tclBind_ .reset(new TclBind(PathConfig::getDataPathString()));179 this->tclThreadManager_ .reset(new TclThreadManager(tclBind_->getTclInterpreter()));188 this->tclBind_ = new TclBind(PathConfig::getDataPathString()); 189 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 180 190 181 191 // Create singletons that always exist (in other libraries) 182 this->rootScope_ .reset(new Scope<ScopeID::Root>());192 this->rootScope_ = new Scope<ScopeID::Root>(); 183 193 184 194 // Generate documentation instead of normal run? … … 198 208 } 199 209 200 /** 201 @brief 202 All destruction code is handled by scoped_ptrs and ScopeGuards. 203 */ 204 Core::~Core() 210 void Core::destroy() 205 211 { 206 212 // Remove us from the object lists again to avoid problems when destroying them 207 213 this->unregisterObject(); 214 215 safeObjectDelete(&graphicsScope_); 216 safeObjectDelete(&guiManager_); 217 safeObjectDelete(&inputManager_); 218 safeObjectDelete(&graphicsManager_); 219 safeObjectDelete(&rootScope_); 220 safeObjectDelete(&tclThreadManager_); 221 safeObjectDelete(&tclBind_); 222 safeObjectDelete(&ioConsole_); 223 safeObjectDelete(&languageInstance_); 224 safeObjectDelete(&configFileManager_); 225 ConsoleCommand::destroyAll(); 226 Identifier::destroyAllIdentifiers(); 227 safeObjectDelete(&signalHandler_); 228 safeObjectDelete(&dynLibManager_); 229 safeObjectDelete(&pathConfig_); 208 230 } 209 231 … … 285 307 286 308 // Calls the InputManager which sets up the input devices. 287 inputManager_ .reset(new InputManager());309 inputManager_ = new InputManager(); 288 310 289 311 // Load the CEGUI interface 290 guiManager_ .reset(new GUIManager(inputManager_->getMousePosition()));312 guiManager_ = new GUIManager(inputManager_->getMousePosition()); 291 313 292 314 bGraphicsLoaded_ = true; … … 297 319 298 320 // Create singletons associated with graphics (in other libraries) 299 graphicsScope_ .reset(new Scope<ScopeID::Graphics>());321 graphicsScope_ = new Scope<ScopeID::Graphics>(); 300 322 301 323 unloader.Dismiss(); … … 304 326 void Core::unloadGraphics() 305 327 { 306 this->graphicsScope_.reset();307 this->guiManager_.reset();308 this->inputManager_.reset();309 this->graphicsManager_.reset();328 safeObjectDelete(&graphicsScope_); 329 safeObjectDelete(&guiManager_); 330 safeObjectDelete(&inputManager_); 331 safeObjectDelete(&graphicsManager_); 310 332 311 333 // Load Ogre::Root again, but without the render system 312 334 try 313 { this->graphicsManager_ .reset(new GraphicsManager(false)); }335 { this->graphicsManager_ = new GraphicsManager(false); } 314 336 catch (...) 315 337 {
Note: See TracChangeset
for help on using the changeset viewer.