From c6dfee706cdfa3a2ec5c9ee8cdedc7811f26d583 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 24 Apr 2013 14:49:52 +0800 Subject: [PATCH] fix memory leak in FontTest --- samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp index 3e8c9d46a2..283b0ebce2 100644 --- a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp @@ -6,6 +6,10 @@ enum { kTagLabel2, kTagLabel3, kTagLabel4, + + kTagColor1, + kTagColor2, + kTagColor3, }; static int fontIdx = 0; @@ -99,6 +103,9 @@ void FontTest::showFont(const char *pFont) removeChildByTag(kTagLabel2, true); removeChildByTag(kTagLabel3, true); removeChildByTag(kTagLabel4, true); + removeChildByTag(kTagColor1, true); + removeChildByTag(kTagColor2, true); + removeChildByTag(kTagColor3, true); CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24); CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize, @@ -133,11 +140,11 @@ void FontTest::showFont(const char *pFont) right->setPosition(ccp(blockSize.width*2, s.height/2)); rightColor->setPosition(right->getPosition()); - this->addChild(leftColor, -1); + this->addChild(leftColor, -1, kTagColor1); this->addChild(left, 0, kTagLabel1); - this->addChild(rightColor, -1); + this->addChild(rightColor, -1, kTagColor2); this->addChild(right, 0, kTagLabel2); - this->addChild(centerColor, -1); + this->addChild(centerColor, -1, kTagColor3); this->addChild(center, 0, kTagLabel3); this->addChild(top, 0, kTagLabel4); }