diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 463b571154..2345e4cf58 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -224,7 +224,11 @@ void CSLoader::destroyCocosStudio() SingleNodeReader::destroyInstance(); SpriteReader::destroyInstance(); ParticleReader::destroyInstance(); + GameMapReader::destroyInstance(); + ProjectNodeReader::destroyInstance(); + ComAudioReader::destroyInstance(); + WidgetReader::destroyInstance(); ButtonReader::destroyInstance(); CheckBoxReader::destroyInstance(); ImageViewReader::destroyInstance(); diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp index 35bede0e21..10d7e0d938 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp @@ -61,7 +61,7 @@ namespace cocostudio return _instanceTMXTiledMapReader; } - void GameMapReader::purge() + void GameMapReader::destroyInstance() { CC_SAFE_DELETE(_instanceTMXTiledMapReader); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h index 24dfafc367..3246147185 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h @@ -42,7 +42,7 @@ namespace cocostudio ~GameMapReader(); static GameMapReader* getInstance(); - static void purge(); + static void destroyInstance(); flatbuffers::Offset createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData, flatbuffers::FlatBufferBuilder* builder); diff --git a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp index fa07c703a5..9772957916 100644 --- a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp +++ b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp @@ -102,6 +102,13 @@ void CocosStudio3DTestDemo::onEnter() BaseTest::onEnter(); } +void CocosStudio3DTestDemo::onExit() +{ + CSLoader::destroyCocosStudio(); + + BaseTest::onExit(); +} + void CocosStudio3DTestDemo::restartCallback(Ref* sender) { auto s = new (std::nothrow) CS3DTestScene(); diff --git a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h index 9f25baf360..0a4597ed38 100644 --- a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h +++ b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h @@ -47,6 +47,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; + virtual void onExit() override; }; class CSNode3DTest : public CocosStudio3DTestDemo diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 74249dd5cf..986ad51c86 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -164,9 +164,8 @@ void ActionTimelineTestLayer::onExit() removeAllChildren(); backItem = restartItem = nextItem = nullptr; - - ActionTimelineCache::getInstance()->purge(); - CSLoader::getInstance()->purge(); + + CSLoader::destroyCocosStudio(); Layer::onExit(); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 012e4500c4..25d2cdf2cd 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -199,6 +199,8 @@ void ArmatureTestLayer::onExit() removeAllChildren(); backItem = restartItem = nextItem = nullptr; + + CSLoader::destroyCocosStudio(); Layer::onExit(); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp index 7159c5fe27..cdd01e9ad5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp @@ -31,6 +31,13 @@ void CustomWidgetCallbackBindScene::onEnter() addChild(pMenu, 1); } +void CustomWidgetCallbackBindScene::onExit() +{ + CSLoader::destroyCocosStudio(); + + Scene::onExit(); +} + void CustomWidgetCallbackBindScene::runThisTest() { CSLoader* instance = CSLoader::getInstance(); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.h index a7c54b0729..74f551e1ab 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.h @@ -10,6 +10,7 @@ class CustomWidgetCallbackBindScene : public TestScene { public: virtual void onEnter() override; + virtual void onExit() override; virtual void runThisTest(); void BackCallback(cocos2d::Ref* pSender); }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp index 3167007133..1e8c2e8e33 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp @@ -19,6 +19,13 @@ UIScene_Editor::~UIScene_Editor() } +void UIScene_Editor::onExit() +{ + CSLoader::destroyCocosStudio(); + + Layer::onExit(); +} + bool UIScene_Editor::init() { if (CCLayer::init()) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h index 15f80cfd2f..a650d5f1e7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h @@ -59,6 +59,8 @@ public: UIScene_Editor(); ~UIScene_Editor(); + virtual void onExit() override; + bool init(); virtual void previousCallback(Ref* sender, Widget::TouchEventType event); virtual void nextCallback(Ref* sender, Widget::TouchEventType event);