diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index a8c3144428..41b6361faf 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -73,21 +73,20 @@ NS_CC_BEGIN // XXX it shoul be a Director ivar. Move it there once support for multiple directors is added // singleton stuff -static CCDisplayLinkDirector s_SharedDirector; +static CCDisplayLinkDirector *s_SharedDirector = NULL; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); CCDirector* CCDirector::sharedDirector(void) { - static bool s_bFirstUseDirector = true; - if (s_bFirstUseDirector) + if (!s_SharedDirector) { - s_bFirstUseDirector = false; - s_SharedDirector.init(); + s_SharedDirector = new CCDisplayLinkDirector(); + s_SharedDirector->init(); } - return &s_SharedDirector; + return s_SharedDirector; } CCDirector::CCDirector(void) @@ -162,7 +161,7 @@ bool CCDirector::init(void) CCDirector::~CCDirector(void) { - CCLOG("cocos2d: deallocing %p", this); + CCLOG("cocos2d: deallocing CCDirector %p", this); CC_SAFE_RELEASE(m_pFPSLabel); CC_SAFE_RELEASE(m_pSPFLabel); @@ -185,6 +184,8 @@ CCDirector::~CCDirector(void) CC_SAFE_DELETE(m_pLastUpdate); // delete fps string delete []m_pszFPS; + + s_SharedDirector = NULL; } void CCDirector::setGLDefaultValues(void) @@ -593,6 +594,7 @@ void CCDirector::purgeDirector() { // cleanup scheduler getScheduler()->unscheduleAllSelectors(); + getActionManager()->removeAllActions(); // don't release the event handlers // They are needed in case the director is run again @@ -643,6 +645,9 @@ void CCDirector::purgeDirector() // OpenGL view m_pobOpenGLView->end(); m_pobOpenGLView = NULL; + + // delete CCDirector + release(); } void CCDirector::setNextScene(void) diff --git a/cocos2dx/platform/mac/CCCommon.mm b/cocos2dx/platform/mac/CCCommon.mm index 1ab9962628..088907e03c 100755 --- a/cocos2dx/platform/mac/CCCommon.mm +++ b/cocos2dx/platform/mac/CCCommon.mm @@ -47,7 +47,7 @@ void CCLog(const char * pszFormat, ...) void CCLuaLog(const char * pszFormat) { - CCLog(pszFormat); + CCLog("%s", pszFormat); } // ios no MessageBox, use CCLog instead diff --git a/cocos2dx/platform/mac/CCDirectorCaller.mm b/cocos2dx/platform/mac/CCDirectorCaller.mm index b6586544ed..dcd6befed2 100755 --- a/cocos2dx/platform/mac/CCDirectorCaller.mm +++ b/cocos2dx/platform/mac/CCDirectorCaller.mm @@ -59,10 +59,15 @@ static id s_sharedDirectorCaller; -(void) dealloc { s_sharedDirectorCaller = nil; - NSLog(@"cocos2d: deallocing CCDirectorCaller %@", self); + CCLOG("cocos2d: deallocing CCDirectorCaller %x", (unsigned int)self); if (displayLink) { CVDisplayLinkRelease(displayLink); } + + CCLOG("--------------------------------------------------------------------------------"); + CCLOG(""); + CCLOG(""); + CCLOG(""); [super dealloc]; }