Skip to content

Commit

Permalink
Fixed cocos2d#12834 Invoke cleanup function when override in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro committed Jul 14, 2015
1 parent 365c51c commit efffea5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cocos/scripting/js-bindings/manual/ScriptingCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/js-tests/src/tests-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var TestController = cc.LayerGradient.extend({
return true;
}
}, this);
}
}
},
onEnter:function(){
this._super();
Expand Down

0 comments on commit efffea5

Please sign in to comment.