From efffea5b91cd45a7edba316d08711662d8c1ad51 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 14 Jul 2015 15:35:29 +0800 Subject: [PATCH] Fixed #12834 Invoke cleanup function when override in JS --- cocos/scripting/js-bindings/manual/ScriptingCore.cpp | 5 +++++ tests/js-tests/src/tests-main.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 6125f8551d47..5b9c7a4ac7b3 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1034,6 +1034,11 @@ int ScriptingCore::handleNodeEvent(void* data) } else if (action == kNodeOnCleanup) { cleanupSchedulesAndActions(p); + + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "cleanup", js_cocos2dx_Node_cleanup)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "cleanup", 1, &dataVal, &retval); + } } return ret; diff --git a/tests/js-tests/src/tests-main.js b/tests/js-tests/src/tests-main.js index ea968c6b46a5..cec384a357da 100644 --- a/tests/js-tests/src/tests-main.js +++ b/tests/js-tests/src/tests-main.js @@ -176,7 +176,7 @@ var TestController = cc.LayerGradient.extend({ return true; } }, this); - } + } }, onEnter:function(){ this._super();