diff --git a/cocos/renderer/CCRenderState.cpp b/cocos/renderer/CCRenderState.cpp index 009794a2f0..054e065034 100644 --- a/cocos/renderer/CCRenderState.cpp +++ b/cocos/renderer/CCRenderState.cpp @@ -50,6 +50,7 @@ RenderState::RenderState() RenderState::~RenderState() { + CC_SAFE_RELEASE(_texture); CC_SAFE_RELEASE(_state); } diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 489d901673..7c966c8644 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -69,6 +69,7 @@ Sprite3DTests::Sprite3DTests() ADD_TEST_CASE(MotionStreak3DTest); ADD_TEST_CASE(Sprite3DPropertyTest); ADD_TEST_CASE(Sprite3DNormalMappingTest); + ADD_TEST_CASE(Issue16155Test); }; //------------------------------------------------------------------ @@ -2588,6 +2589,9 @@ std::string Sprite3DNormalMappingTest::subtitle() const return ""; } +// +// +// Sprite3DPropertyTest::Sprite3DPropertyTest() { auto s = Director::getInstance()->getWinSize(); @@ -2688,4 +2692,25 @@ void Sprite3DPropertyTest::refreshSpriteRender() } mesh->setTexture(cacheTex, cocos2d::NTextureData::Usage::Diffuse, false); } -} \ No newline at end of file +} + +// +// Issue16155Test +// +Issue16155Test::Issue16155Test() +{ + auto s = Director::getInstance()->getWinSize(); + + auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + addChild(sprite); + removeChild(sprite); +} + +std::string Issue16155Test::title() const +{ + return "Issue16155 Test"; +} +std::string Issue16155Test::subtitle() const +{ + return "Should not leak texture"; +} diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index bbfd47652c..6a1181fd06 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -615,4 +615,13 @@ protected: std::string _texFile; }; +class Issue16155Test : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Issue16155Test); + Issue16155Test(); + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + #endif