From a5da6d71b434b4866cc97aa99c714e084c60ebfa Mon Sep 17 00:00:00 2001 From: mgcL Date: Sat, 5 Apr 2014 21:09:49 +0800 Subject: [PATCH 1/2] add destroyInstance for ScriptHandlerMgr --- .../scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp | 7 +++++++ cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp index 5d571b778e..765f0ac756 100644 --- a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp @@ -124,10 +124,12 @@ ScriptHandlerMgr::ScriptHandlerMgr() { } + ScriptHandlerMgr::~ScriptHandlerMgr() { CC_SAFE_DELETE(_scriptHandlerMgr); } + ScriptHandlerMgr* ScriptHandlerMgr::getInstance() { if (NULL == _scriptHandlerMgr) @@ -138,6 +140,11 @@ ScriptHandlerMgr* ScriptHandlerMgr::getInstance() return _scriptHandlerMgr; } +void ScriptHandlerMgr::destroyInstance() +{ + CC_SAFE_DELETE(_scriptHandlerMgr); +} + void ScriptHandlerMgr::init() { _mapObjectHandlers.clear(); diff --git a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.h b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.h index f367859afc..aab6f716ae 100644 --- a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.h @@ -173,7 +173,8 @@ public: ScriptHandlerMgr(void); virtual ~ScriptHandlerMgr(void); static ScriptHandlerMgr* getInstance(void); - + static void destroyInstance(void); + void addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType); void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType); int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType); From d9e0124ff8a8ebc55d0748b14207743727a8f73e Mon Sep 17 00:00:00 2001 From: mgcL Date: Sat, 5 Apr 2014 21:26:56 +0800 Subject: [PATCH 2/2] delete _scriptHandlerMgr in destruct will cause stack overflow --- cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp index 765f0ac756..6f5fa121e4 100644 --- a/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaScriptHandlerMgr.cpp @@ -127,7 +127,6 @@ ScriptHandlerMgr::ScriptHandlerMgr() ScriptHandlerMgr::~ScriptHandlerMgr() { - CC_SAFE_DELETE(_scriptHandlerMgr); } ScriptHandlerMgr* ScriptHandlerMgr::getInstance()