Skip to content

Commit

Permalink
fixed cocos2d#1562:fix a memory leak in CCLabelBMFont
Browse files Browse the repository at this point in the history
  • Loading branch information
minggo committed Nov 19, 2012
1 parent ac69b9d commit baa0a45
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cocos2dx/label_nodes/CCLabelBMFont.cpp
Expand Up @@ -429,6 +429,7 @@ CCBMFontConfiguration::CCBMFontConfiguration()
: m_pFontDefDictionary(NULL)
, m_nCommonHeight(0)
, m_pKerningDictionary(NULL)
, m_pCharacterSet(NULL)
{

}
Expand Down Expand Up @@ -815,8 +816,9 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f
m_bIsOpacityModifyRGB = m_pobTextureAtlas->getTexture()->hasPremultipliedAlpha();
m_obAnchorPoint = ccp(0.5f, 0.5f);

m_pReusedChar = CCSprite::create();
m_pReusedChar = new CCSprite();
m_pReusedChar->initWithTexture(m_pobTextureAtlas->getTexture(), CCRectMake(0, 0, 0, 0), false);
m_pReusedChar->setBatchNode(this);

this->setString(theString);

Expand All @@ -838,6 +840,7 @@ CCLabelBMFont::CCLabelBMFont()

CCLabelBMFont::~CCLabelBMFont()
{
CC_SAFE_RELEASE(m_pReusedChar);
CC_SAFE_DELETE(m_sString);
CC_SAFE_RELEASE(m_pConfiguration);
}
Expand Down Expand Up @@ -948,7 +951,7 @@ void CCLabelBMFont::createFontChars()
}
else
{
fontChar = CCSprite::create();
fontChar = new CCSprite();
fontChar->initWithTexture(m_pobTextureAtlas->getTexture(), rect);
addChild(fontChar, i, i);
fontChar->release();
Expand Down

0 comments on commit baa0a45

Please sign in to comment.