[wophone]Resolve the memory leak of CCAccelerometer.

This commit is contained in:
natural-law 2011-03-11 17:41:19 +08:00
parent 6d028007c2
commit dd675f8cf1
2 changed files with 17 additions and 6 deletions

View File

@ -147,6 +147,22 @@ void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate)
void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
{
CCAccelerometerHandler *pHandlerIter;
CCMutableArray<CCAccelerometerHandler*>::CCMutableArrayIterator iter;
if (pDelegate)
{
for (iter = m_pDelegates->begin(); iter != m_pDelegates->end(); ++iter)
{
pHandlerIter = *iter;
if (pHandlerIter && pHandlerIter->getDelegate() == pDelegate)
{
// this delegate have existed
return;
}
}
}
CCAccelerometerHandler* pHandler = CCAccelerometerHandler::handlerWithDelegate(pDelegate);
if (pHandler)

View File

@ -978,12 +978,7 @@ void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame)
CCTexture2D *pNewTexture = pNewFrame->getTexture();
// update texture before updating texture rect
if ((pNewTexture && m_pobTexture) &&
(pNewTexture->getName() == m_pobTexture->getName()))
{
// new texture is same with the current texture,nothing to do
}
else
if (pNewTexture != m_pobTexture)
{
setTexture(pNewTexture);
}