Mercurial > fife-parpg
changeset 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 | fe7ff4808529 |
children | e7a431577c95 |
files | SConstruct doc/dependencies/moduledeps.png engine/core/controller/engine.cpp engine/core/controller/engine.h engine/core/controller/engine.i engine/core/util/resource/pool.cpp engine/extensions/basicapplication.py tests/swig_tests/action_tests.py tests/swig_tests/audio_tests.py tests/swig_tests/controller_tests.py tests/swig_tests/eventchannel_tests.py tests/swig_tests/gui_tests.py tests/swig_tests/resource_tests.py tests/swig_tests/timer_tests.py tests/swig_tests/vfs_tests.py tests/swig_tests/video_tests.py tests/swig_tests/view_tests.py |
diffstat | 17 files changed, 35 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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() {
--- 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; };
--- 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();
--- 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<ResourceLoader*>::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()); } }
--- 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):
--- 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'
--- 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):
--- 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"
--- 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()
--- 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)
--- 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()
--- 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)
--- 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('.')
--- 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()