diff 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
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp	Tue Oct 07 02:12:57 2008 +0000
+++ b/engine/core/controller/engine.cpp	Thu Oct 09 06:18:36 2008 +0000
@@ -140,6 +140,7 @@
 		//m_vfs->addProvider(ProviderDAT2());
 		//m_vfs->addProvider(ProviderDAT1());
 		FL_LOG(_log, "Engine pre-init done");
+		m_destroyed = false;
 	}
 
 	void Engine::init() {
@@ -254,6 +255,12 @@
 	}
 
 	Engine::~Engine() {
+		if( !m_destroyed ) {
+			destroy();
+		}
+	}
+
+	void Engine::destroy() {
 		FL_LOG(_log, "Destructing engine");
  		delete m_cursor;
  		delete m_view;
@@ -262,9 +269,6 @@
 		delete m_guimanager;
 		delete m_gui_graphics;
 
-		m_renderbackend->deinit();
-		delete m_renderbackend;
-
 		// Note the dependancy between image and animation pools
 		// as animations reference images they have to be deleted
 		// before clearing the image pool.
@@ -272,6 +276,9 @@
 		delete m_imagepool;
 		delete m_eventmanager;
 
+		m_renderbackend->deinit();
+		delete m_renderbackend;
+
 		delete m_vfs;
 
 		delete m_timemanager;
@@ -279,6 +286,7 @@
 		TTF_Quit();
 		SDL_Quit();
 		FL_LOG(_log, "================== Engine destructed ==================");
+		m_destroyed = true;
 		//delete m_logmanager;
 	}
 	void Engine::initializePumping() {