issue #1114: fixed some memory leaks in CCControlExtension.

This commit is contained in:
James Chen 2012-04-17 17:14:59 +08:00
parent 14c10a470a
commit 75da752aa9
2 changed files with 46 additions and 46 deletions

View File

@ -69,10 +69,10 @@ CCControl::~CCControl()
CC_SAFE_RELEASE(dispatchTable);
}
//Menu - Events
void CCControl::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
//Menu - Events
void CCControl::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
}
void CCControl::onEnter()
@ -139,7 +139,7 @@ void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHan
{
// Create the invocation object
CCInvocation *invocation=new CCInvocation(target, action, controlEvent);
invocation->autorelease();
// Add the invocation into the dispatch list for the given control event
CCArray* eventInvocationList = dispatchListforControlEvent(controlEvent);
eventInvocationList->addObject(invocation);
@ -208,65 +208,65 @@ void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_Menu
void CCControl::setColor(const ccColor3B& color)
{
m_tColor=color;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setColor(m_tColor);
}
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setColor(m_tColor);
}
}
}
const ccColor3B& CCControl::getColor(void)
{
return m_tColor;
const ccColor3B& CCControl::getColor(void)
{
return m_tColor;
}
void CCControl::setOpacity(GLubyte opacity)
{
m_cOpacity = opacity;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setOpacity(opacity);
}
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setOpacity(opacity);
}
}
}
GLubyte CCControl::getOpacity()
{
return m_cOpacity;
GLubyte CCControl::getOpacity()
{
return m_cOpacity;
}
void CCControl::setIsOpacityModifyRGB(bool opacityModifyRGB)
{
m_bIsOpacityModifyRGB=opacityModifyRGB;
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setIsOpacityModifyRGB(opacityModifyRGB);
}
CCObject* child;
CCArray* children=getChildren();
CCARRAY_FOREACH(children, child)
{
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
if (pNode)
{
pNode->setIsOpacityModifyRGB(opacityModifyRGB);
}
}
}
bool CCControl::getIsOpacityModifyRGB()
{
return m_bIsOpacityModifyRGB;
bool CCControl::getIsOpacityModifyRGB()
{
return m_bIsOpacityModifyRGB;
}

View File

@ -96,7 +96,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr
// Initialize the dispatch table
CCString* tempString=new CCString(label->getString());
CCString* tempString = CCString::stringWithCString(label->getString());
//tempString->autorelease();
setTitleForState(tempString, CCControlStateNormal);
setTitleColorForState(rgbaLabel->getColor(), CCControlStateNormal);
@ -246,10 +246,10 @@ const ccColor3B CCControlButton::getTitleColorForState(CCControlState state)
void CCControlButton::setTitleColorForState(ccColor3B color, CCControlState state)
{
//ccColor3B* colorValue=&color;
CCColor3bObject* previousObject=(CCColor3bObject*)m_titleColorDispatchTable->objectForKey(state);
CC_SAFE_RELEASE(previousObject);
m_titleColorDispatchTable->removeObjectForKey(state);
m_titleColorDispatchTable->setObject(new CCColor3bObject(color), state);
CCColor3bObject* pColor3bObject = new CCColor3bObject(color);
pColor3bObject->autorelease();
m_titleColorDispatchTable->setObject(pColor3bObject, state);
// If the current state if equal to the given state we update the layout
if (getState() == state)