From 2b5af669746bab85ee8d4b63d1e9a70a3143a5dd Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 10 Apr 2012 23:09:58 +0800 Subject: [PATCH 1/2] updated win32 projects configuration release version. --- HelloWorld/win32/HelloWorld.win32.vcproj | 2 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 4 ++-- tests/test.win32/test.win32.vcproj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HelloWorld/win32/HelloWorld.win32.vcproj b/HelloWorld/win32/HelloWorld.win32.vcproj index 70d71b3243..82fb736c7d 100644 --- a/HelloWorld/win32/HelloWorld.win32.vcproj +++ b/HelloWorld/win32/HelloWorld.win32.vcproj @@ -119,7 +119,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes" + AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" RuntimeLibrary="2" EnableFunctionLevelLinking="true" diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 5d192e97c7..3ed64ef57b 100644 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -124,7 +124,7 @@ /> Date: Wed, 11 Apr 2012 12:03:37 +0800 Subject: [PATCH 2/2] Fixed a heap crash in CCDirector, and reverted CCDirector singleton to global variable rather than a pointer. --- cocos2dx/CCDirector.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 9bc1fa43ca..3d11c35348 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -69,20 +69,21 @@ 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_pSharedDirector = NULL; +static CCDisplayLinkDirector s_SharedDirector; #define kDefaultFPS 60 // 60 frames per second extern const char* cocos2dVersion(void); CCDirector* CCDirector::sharedDirector(void) { - if (s_pSharedDirector == NULL) + static bool s_bFirstUseDirector = true; + if (s_bFirstUseDirector) { - s_pSharedDirector = new CCDisplayLinkDirector(); - s_pSharedDirector->init(); + s_bFirstUseDirector = false; + s_SharedDirector.init(); } - - return s_pSharedDirector; + + return &s_SharedDirector; } CCDirector::CCDirector(void) @@ -673,7 +674,6 @@ void CCDirector::purgeDirector() // OpenGL view m_pobOpenGLView->release(); m_pobOpenGLView = NULL; - CC_SAFE_DELETE(s_pSharedDirector); } void CCDirector::setNextScene(void) @@ -1008,8 +1008,8 @@ void CCDisplayLinkDirector::mainLoop(void) { if (m_bPurgeDirecotorInNextLoop) { - purgeDirector(); m_bPurgeDirecotorInNextLoop = false; + purgeDirector(); } else if (! m_bInvalid) {