From 6e8c46d0be586a2f6d199e3f428d763c468c75ca Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sun, 21 Feb 2016 20:20:32 +0800 Subject: [PATCH] Fix lua engine crashes caused by CC_ENABLE_GC_FOR_NATIVE_OBJECTS --- cocos/base/CCRef.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/base/CCRef.cpp b/cocos/base/CCRef.cpp index c7f1a7bb8e..aa79db0b26 100644 --- a/cocos/base/CCRef.cpp +++ b/cocos/base/CCRef.cpp @@ -61,12 +61,13 @@ Ref::Ref() Ref::~Ref() { -#if CC_ENABLE_SCRIPT_BINDING && !CC_ENABLE_GC_FOR_NATIVE_OBJECTS +#if CC_ENABLE_SCRIPT_BINDING // if the object is referenced by Lua engine, remove it if (_luaID) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptObjectByObject(this); } +#if !CC_ENABLE_GC_FOR_NATIVE_OBJECTS else { ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); @@ -75,7 +76,8 @@ Ref::~Ref() pEngine->removeScriptObjectByObject(this); } } -#endif +#endif // !CC_ENABLE_GC_FOR_NATIVE_OBJECTS +#endif // CC_ENABLE_SCRIPT_BINDING #if CC_REF_LEAK_DETECTION