Merge pull request #15974 from pandamicro/v3.12

Fix window.close crash in JSB
This commit is contained in:
minggo 2016-06-28 13:54:36 +08:00 committed by GitHub
commit 3327d3661a
1 changed files with 7 additions and 1 deletions

View File

@ -386,7 +386,13 @@ bool JSB_core_restartVM(JSContext *cx, uint32_t argc, jsval *vp)
bool JSB_closeWindow(JSContext *cx, uint32_t argc, jsval *vp) bool JSB_closeWindow(JSContext *cx, uint32_t argc, jsval *vp)
{ {
EventListenerCustom* _event = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_AFTER_DRAW, [&](EventCustom *event) {
Director::getInstance()->getEventDispatcher()->removeEventListener(_event);
_event->release();
ScriptingCore::getInstance()->cleanup(); ScriptingCore::getInstance()->cleanup();
});
_event->retain();
Director::getInstance()->end(); Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0); exit(0);