From fe1336bdc764b99f953b843773f4c49c47575836 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 25 Dec 2015 18:41:09 +0800 Subject: [PATCH] Fix chipmunk cpSpaceAddCollisionHandler issue on argument parsing --- .../manual/chipmunk/js_bindings_chipmunk_manual.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 34e4d42722..8065b71476 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -970,6 +970,9 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments"); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue spaceVal(cx, args.get(0)); + JS::RootedObject jsspace(cx); + JS_ValueToObject(cx, spaceVal, &jsspace); // args cpSpace *space = nullptr; @@ -978,7 +981,6 @@ bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) bool ok = jsval_to_opaque(cx, jsarg, (void**)&space); JSB_PRECONDITION(ok, "Error parsing arguments"); - JS::RootedObject jsspace(cx, jsarg.toObjectOrNull()); return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, jsspace, space, 0); }