@
bool CCLabelTTF::updateTexture()
{
bool bRet = false;
CCTexture2D tex;
do
{
// let system compute label’s width or height when its value is 0
// refer to cocos2d-x issue #1430
tex = new CCTexture2D;
CC_BREAK_IF;
bRet = tex~~>initWithString,
m_pFontName~~>c_str,
m_fFontSize CC_CONTENT_SCALE_FACTOR(),
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
m_hAlignment,
m_vAlignment);
CC_BREAK_IF(!bRet);
this~~>setTexture;
tex~~>release();
CCRect rect = CCRectZero;
rect.size = m_pobTexture~~>getContentSize;
this~~>setTextureRect(rect);
}while(false);
return bRet;
}
@
bRet = tex~~>initWithString
if this fails, tex~~>release() is never called and tex gets leaked. I’m seeing this in Instruments but I haven’t constructed a specific example to test it. Hopefully this gets the devs attention.
I have same problem. How to fix it
oops, anyone can help us?
tex = new CCTexture2D();
>
Note: using new() instead of create(). This means no reference counter logic is called. tex is also implicitly “retained” because of this.
tex~~>release;
Actually tries to deref something that we use the reference counter create function on. But even if we do technically have a retained tex, we never actually call the reference counter, and the reference counter is never updated.
Not to mention the profiler sees no sign of a delete because we’re using release instead.
And so we get a leak message.
Can someone confirm if the object is actually removed and we can safely ignore this? If not, I’ll see what happens if I just throw a ::create inside CCTexture2D.
Edit: nope, cloning a CCobject::create inside CCTexture2D doesn’t work~~ all I get is a “not implement” message when it tries to call m_pobTexture->getContentSize().