From 1d79eecc6edcec71dfcd85c51476d8587ffbbf59 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 9 Aug 2017 14:50:54 +0800 Subject: [PATCH] Fix crash issue during closing if scene has a label outline component --- .../scripting/js-bindings/manual/ScriptingCore.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index f0f5925f61..8e12a89d5f 100644 --- a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -937,6 +937,12 @@ bool ScriptingCore::requireScript(const char *path, JS::HandleObject global, JSC void ScriptingCore::reset() { Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(EVENT_RESET); + + // Cleanup js objects + JS::RootedObject global(_cx, _global->get()); + JS::RootedValue globalVal(_cx, JS::ObjectOrNullValue(global)); + executeFunctionWithOwner(globalVal, "__cleanup", JS::HandleValueArray::empty()); + Director::getInstance()->restart(); } @@ -963,13 +969,6 @@ void ScriptingCore::cleanup() // clear http client callbacks network::HttpClient::destroyInstance(); - { - // Cleanup js objects - JS::RootedObject global(_cx, _global->get()); - JS::RootedValue globalVal(_cx, JS::ObjectOrNullValue(global)); - executeFunctionWithOwner(globalVal, "__cleanup", JS::HandleValueArray::empty()); - } - // Clear all cached script cleanAllScript();