From 6864a4a7bbdb9ce7e21b21d4ffe6428516e8a3f7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 18 Apr 2015 15:06:09 +0800 Subject: [PATCH] [Director FIX]: Clean all scheduler and remove all eventlisteners after exiting scene --- cocos/base/CCDirector.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index fdb9ccffe8..c8788d2eea 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -937,16 +937,7 @@ void Director::restart() } void Director::reset() -{ - // cleanup scheduler - getScheduler()->unscheduleAll(); - - // Remove all events - if (_eventDispatcher) - { - _eventDispatcher->removeAllEventListeners(); - } - +{ if (_runningScene) { _runningScene->onExit(); @@ -956,6 +947,15 @@ void Director::reset() _runningScene = nullptr; _nextScene = nullptr; + + // cleanup scheduler + getScheduler()->unscheduleAll(); + + // Remove all events + if (_eventDispatcher) + { + _eventDispatcher->removeAllEventListeners(); + } // remove all objects, but don't release it. // runWithScene might be executed after 'end'.