# HG changeset patch # User phoku@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1223533116 0 # Node ID d2f1e81fbe2c5f4995ff11f2ba21507bfb79158b # Parent fe7ff4808529ffcd552c132f1c429473ca5cf9a9 * 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. diff -r fe7ff4808529 -r d2f1e81fbe2c SConstruct --- a/SConstruct Tue Oct 07 02:12:57 2008 +0000 +++ b/SConstruct Thu Oct 09 06:18:36 2008 +0000 @@ -70,7 +70,7 @@ configcall = '%s --libs --cflags' %binary return tryConfigCommand(context, configcall) -def checkSimpleLib(context, liblist, header = '', lang = 'c', required = 1): +def checkSimpleLib(context, liblist, header = '', lang = 'c++', required = 1): for lib in liblist: ret = checkPKG(context, lib) if ret: @@ -83,7 +83,7 @@ if len(header): ret = conf.CheckLibWithHeader(lib, header, lang) else: - ret = conf.CheckLib(lib) + ret = conf.CheckLib(lib,language=lang) if ret: # print "ret: " + ret diff -r fe7ff4808529 -r d2f1e81fbe2c doc/dependencies/moduledeps.png Binary file doc/dependencies/moduledeps.png has changed diff -r fe7ff4808529 -r d2f1e81fbe2c engine/core/controller/engine.cpp --- 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() { diff -r fe7ff4808529 -r d2f1e81fbe2c engine/core/controller/engine.h --- a/engine/core/controller/engine.h Tue Oct 07 02:12:57 2008 +0000 +++ b/engine/core/controller/engine.h Thu Oct 09 06:18:36 2008 +0000 @@ -82,6 +82,10 @@ /** Initializes the engine */ void init(); + + /** Explicit destruction of engine + */ + void destroy(); /** Initializes the continuous processing of the engine * Call this only once in your program @@ -172,7 +176,7 @@ LogManager* m_logmanager; GuiFont* m_defaultfont; Cursor* m_cursor; - + bool m_destroyed; EngineSettings m_settings; }; diff -r fe7ff4808529 -r d2f1e81fbe2c engine/core/controller/engine.i --- a/engine/core/controller/engine.i Tue Oct 07 02:12:57 2008 +0000 +++ b/engine/core/controller/engine.i Thu Oct 09 06:18:36 2008 +0000 @@ -89,6 +89,7 @@ EngineSettings& getSettings(); void init(); + void destroy(); SoundManager* getSoundManager(); EventManager* getEventManager(); diff -r fe7ff4808529 -r d2f1e81fbe2c engine/core/util/resource/pool.cpp --- a/engine/core/util/resource/pool.cpp Tue Oct 07 02:12:57 2008 +0000 +++ b/engine/core/util/resource/pool.cpp Thu Oct 09 06:18:36 2008 +0000 @@ -45,6 +45,8 @@ } Pool::~Pool() { + FL_LOG(_log, LMsg("Pool destroyed ")); + printStatistics(); clear(); std::vector::iterator loader; for (loader = m_loaders.begin(); loader != m_loaders.end(); loader++) { @@ -209,6 +211,8 @@ } void Pool::printStatistics() { - FL_LOG(_log, LMsg("Pool size =") << m_entries.size()); + FL_LOG(_log, LMsg("Pool not loaded =") << getResourceCount(RES_NON_LOADED)); + FL_LOG(_log, LMsg("Pool loaded =") << getResourceCount(RES_LOADED)); + FL_LOG(_log, LMsg("Pool total size =") << m_entries.size()); } } diff -r fe7ff4808529 -r d2f1e81fbe2c engine/extensions/basicapplication.py --- a/engine/extensions/basicapplication.py Tue Oct 07 02:12:57 2008 +0000 +++ b/engine/extensions/basicapplication.py Thu Oct 09 06:18:36 2008 +0000 @@ -115,6 +115,7 @@ self.engine.initializePumping() retval = self.mainLoop() self.engine.finalizePumping() + self.engine.destroy() return retval def mainLoop(self): diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/action_tests.py --- a/tests/swig_tests/action_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/action_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -45,7 +45,7 @@ fife.InstanceVisual.create(self.inst) def tearDown(self): - del self.engine + self.engine.destroy() def _testWalkingAction(self): print 'test1' diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/audio_tests.py --- a/tests/swig_tests/audio_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/audio_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -12,7 +12,7 @@ self.soundmanager.init() def tearDown(self): - del self.engine + self.engine.destroy() del self.log def testLeftRight(self): diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/controller_tests.py --- a/tests/swig_tests/controller_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/controller_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -7,7 +7,7 @@ self.engine = getEngine(True) def tearDown(self): - del self.engine + self.engine.destroy() def testInstances(self): print "\nTest SoundManager" diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/eventchannel_tests.py --- a/tests/swig_tests/eventchannel_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/eventchannel_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -15,7 +15,7 @@ self.eventmanager = self.engine.getEventManager() def tearDown(self): - del self.engine + self.engine.destroy() def testEvents(self): l = MyEventListener() diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/gui_tests.py --- a/tests/swig_tests/gui_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/gui_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -9,7 +9,7 @@ self.renderbackend = self.engine.getRenderBackend() def tearDown(self): - del self.engine + self.engine.destroy() def testFonts(self): ttffont = fife.TTFont('tests/data/FreeMono.ttf', 14) diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/resource_tests.py --- a/tests/swig_tests/resource_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/resource_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -10,7 +10,7 @@ self.engine = getEngine() def tearDown(self): - del self.engine + self.engine.destroy() def testImagePool(self): pool = self.engine.getImagePool() diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/timer_tests.py --- a/tests/swig_tests/timer_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/timer_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -17,7 +17,7 @@ self.timemanager = self.engine.getTimeManager() def tearDown(self): - del self.engine + self.engine.destroy() def testEvents(self): e = MyTimeEvent(100) diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/vfs_tests.py --- a/tests/swig_tests/vfs_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/vfs_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -9,7 +9,7 @@ self.vfs = self.engine.getVFS() def tearDown(self): - del self.engine + self.engine.destroy() def testListFiles(self): self.vfs.listFiles('.') diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/video_tests.py --- a/tests/swig_tests/video_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/video_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -8,7 +8,7 @@ self.engine = getEngine() def tearDown(self): - del self.engine + self.engine.destroy() def testSimpleAnimation(self): pool = self.engine.getAnimationPool() diff -r fe7ff4808529 -r d2f1e81fbe2c tests/swig_tests/view_tests.py --- a/tests/swig_tests/view_tests.py Tue Oct 07 02:12:57 2008 +0000 +++ b/tests/swig_tests/view_tests.py Thu Oct 09 06:18:36 2008 +0000 @@ -33,7 +33,7 @@ def tearDown(self): - del self.engine + self.engine.destroy() def testCamera(self): rb = self.engine.getRenderBackend()