comparison engine/core/controller/engine.cpp @ 144:d2f1e81fbe2c

* Fixed a scons issue, where libraries checked for C instead of C++ * Fixed a shutdown order problem - deleting a GLImage will reference the RenderBackend, thus image pools must be deleted first. * Added an explicit Engine.destroy method to force the shutdown, in case python fails to do so. Necessary - see above. * The Pool::printStatistics now gives out information how many resources are loaded. Called before destruction. Add 'pool' to the LogModules to check memory pooling issues.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 09 Oct 2008 06:18:36 +0000
parents 46de6c7e22e5
children bb9902910067
comparison
equal deleted inserted replaced
143:fe7ff4808529 144:d2f1e81fbe2c
138 m_vfs->addProvider( new ZipProvider() ); 138 m_vfs->addProvider( new ZipProvider() );
139 #endif 139 #endif
140 //m_vfs->addProvider(ProviderDAT2()); 140 //m_vfs->addProvider(ProviderDAT2());
141 //m_vfs->addProvider(ProviderDAT1()); 141 //m_vfs->addProvider(ProviderDAT1());
142 FL_LOG(_log, "Engine pre-init done"); 142 FL_LOG(_log, "Engine pre-init done");
143 m_destroyed = false;
143 } 144 }
144 145
145 void Engine::init() { 146 void Engine::init() {
146 FL_LOG(_log, "Engine initialize start"); 147 FL_LOG(_log, "Engine initialize start");
147 m_settings.validate(); 148 m_settings.validate();
252 m_cursor = new Cursor(m_imagepool, m_animpool, m_renderbackend); 253 m_cursor = new Cursor(m_imagepool, m_animpool, m_renderbackend);
253 FL_LOG(_log, "Engine intialized"); 254 FL_LOG(_log, "Engine intialized");
254 } 255 }
255 256
256 Engine::~Engine() { 257 Engine::~Engine() {
258 if( !m_destroyed ) {
259 destroy();
260 }
261 }
262
263 void Engine::destroy() {
257 FL_LOG(_log, "Destructing engine"); 264 FL_LOG(_log, "Destructing engine");
258 delete m_cursor; 265 delete m_cursor;
259 delete m_view; 266 delete m_view;
260 delete m_model; 267 delete m_model;
261 delete m_soundmanager; 268 delete m_soundmanager;
262 delete m_guimanager; 269 delete m_guimanager;
263 delete m_gui_graphics; 270 delete m_gui_graphics;
264 271
265 m_renderbackend->deinit();
266 delete m_renderbackend;
267
268 // Note the dependancy between image and animation pools 272 // Note the dependancy between image and animation pools
269 // as animations reference images they have to be deleted 273 // as animations reference images they have to be deleted
270 // before clearing the image pool. 274 // before clearing the image pool.
271 delete m_animpool; 275 delete m_animpool;
272 delete m_imagepool; 276 delete m_imagepool;
273 delete m_eventmanager; 277 delete m_eventmanager;
274 278
279 m_renderbackend->deinit();
280 delete m_renderbackend;
281
275 delete m_vfs; 282 delete m_vfs;
276 283
277 delete m_timemanager; 284 delete m_timemanager;
278 285
279 TTF_Quit(); 286 TTF_Quit();
280 SDL_Quit(); 287 SDL_Quit();
281 FL_LOG(_log, "================== Engine destructed =================="); 288 FL_LOG(_log, "================== Engine destructed ==================");
289 m_destroyed = true;
282 //delete m_logmanager; 290 //delete m_logmanager;
283 } 291 }
284 void Engine::initializePumping() { 292 void Engine::initializePumping() {
285 m_eventmanager->processEvents(); 293 m_eventmanager->processEvents();
286 } 294 }