fix: release texture in RenderState (#16396)

memory leak fixed in RenderState

fixes github issue #16155
This commit is contained in:
Ricardo Quesada 2016-08-19 00:22:57 -07:00 committed by GitHub
parent d09ee83c5a
commit 016e7b0dfc
3 changed files with 36 additions and 1 deletions

View File

@ -50,6 +50,7 @@ RenderState::RenderState()
RenderState::~RenderState()
{
CC_SAFE_RELEASE(_texture);
CC_SAFE_RELEASE(_state);
}

View File

@ -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);
}
}
}
//
// 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";
}

View File

@ -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