# HG changeset patch # User mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1245598992 0 # Node ID fdb1e98fd8b6cec4568ae020338b3cf940bf9dcb # Parent bbabe4942150dfa77c7426590aa1dee2b7d3f2a9 * Create an autorelease pool, so autoreleased SDL objects don't leak (Mac OS X specific issue) * Patch by nschum diff -r bbabe4942150 -r fdb1e98fd8b6 build/darwin-config-dist.py --- a/build/darwin-config-dist.py Sun Jun 21 15:09:54 2009 +0000 +++ b/build/darwin-config-dist.py Sun Jun 21 15:43:12 2009 +0000 @@ -46,6 +46,7 @@ context.CheckHeader('SDL/SDL_image.h') context.CheckHeader('SDL/SDL_ttf.h') + context.checkSimpleLib(['objc']) context.checkSimpleLib(['vorbisfile'], 'vorbisfile.h') context.checkSimpleLib(['guichan']) context.checkSimpleLib(['guichan_sdl']) diff -r bbabe4942150 -r fdb1e98fd8b6 engine/core/controller/engine.cpp --- a/engine/core/controller/engine.cpp Sun Jun 21 15:09:54 2009 +0000 +++ b/engine/core/controller/engine.cpp Sun Jun 21 15:43:12 2009 +0000 @@ -77,6 +77,8 @@ #include "engine.h" #ifdef USE_COCOA + +#include #include int main(int argc, char **argv) @@ -112,6 +114,11 @@ void (*nsappload)(void); nsappload = (void(*)()) dlsym( cocoa_lib, "NSApplicationLoad"); nsappload(); + + // Create an autorelease pool, so autoreleased SDL objects don't leak. + objc_object *NSAutoreleasePool = objc_getClass("NSAutoreleasePool"); + m_autoreleasePool = + objc_msgSend(NSAutoreleasePool, sel_registerName("new")); #endif preInit(); } @@ -281,6 +288,9 @@ TTF_Quit(); SDL_Quit(); +#ifdef USE_COCOA + objc_msgSend(m_autoreleasePool, sel_registerName("release")); +#endif FL_LOG(_log, "================== Engine destructed =================="); m_destroyed = true; //delete m_logmanager; diff -r bbabe4942150 -r fdb1e98fd8b6 engine/core/controller/engine.h --- a/engine/core/controller/engine.h Sun Jun 21 15:09:54 2009 +0000 +++ b/engine/core/controller/engine.h Sun Jun 21 15:43:12 2009 +0000 @@ -27,6 +27,11 @@ #include #include +// Platform specific includes +#ifdef USE_COCOA +#include +#endif + // 3rd party library includes #include @@ -179,6 +184,11 @@ bool m_destroyed; EngineSettings m_settings; + +#ifdef USE_COCOA + objc_object *m_autoreleasePool; +#endif + }; }//FIFE