From 5c8d24a11e5ec4a734b483c1bf1910b213d626d9 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Mon, 18 Nov 2013 14:12:07 +0800 Subject: [PATCH] hot fix:Repair the crash of cocostudio and the bug of some lua test samples can't come in --- .../cocosbuilder/CCBAnimationManager.cpp | 16 ++++++++++------ .../lua/bindings/LuaBasicConversions.cpp | 4 ++-- .../bindings/lua_cocos2dx_extension_manual.cpp | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index 3d7c7aae4b..df8721de0d 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -622,9 +622,9 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann Array *actions = Array::create(); Array *keyframes = channel->getKeyframes(); - int numKeyframes = keyframes->count(); + long numKeyframes = keyframes->count(); - for (int i = 0; i < numKeyframes; ++i) + for (long i = 0; i < numKeyframes; ++i) { CCBKeyframe *keyframe = (CCBKeyframe*)keyframes->getObjectAtIndex(i); @@ -640,10 +640,14 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann if(_jsControlled) { String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str()); - CallFunc *callback = ((CallFunc*)(_keyframeCallFuncs->objectForKey(callbackName->getCString())))->clone(); - - if(callback != NULL) { - actions->addObject(callback); + Object* callback = _keyframeCallFuncs->objectForKey(callbackName->getCString()); + if (nullptr != callback) + { + CallFunc *callbackClone = (static_cast(callback))->clone(); + + if(callbackClone != NULL) { + actions->addObject(callbackClone); + } } } else diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 6fe9afcd00..ef080cb288 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -1203,7 +1203,7 @@ void array_to_luaval(lua_State* L,Array* inValue) if (nullptr == obj) continue; - uint32_t typeId = typeid(*obj).hash_code(); + long typeId = typeid(*obj).hash_code(); auto iter = g_luaType.find(typeId); if (g_luaType.end() != iter) { @@ -1292,7 +1292,7 @@ void dictionary_to_luaval(lua_State* L, Dictionary* dict) if (NULL == element) continue; - uint32_t typeId = typeid(element->getObject()).hash_code(); + long typeId = typeid(element->getObject()).hash_code(); auto iter = g_luaType.find(typeId); if (g_luaType.end() != iter) diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index 2822c7aa7a..20f88e35d1 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -691,7 +691,7 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); - uint32_t typeId = typeid(CCBProxy).hash_code(); + long typeId = typeid(CCBProxy).hash_code(); g_luaType[typeId] = "CCBProxy"; return 1; }