Merge pull request #2234 from dumganhar/memory-leak

Fixing memoryleaks.
This commit is contained in:
minggo 2013-03-20 18:32:19 -07:00
commit 66f9623fcd
5 changed files with 13 additions and 11 deletions

View File

@ -375,7 +375,6 @@ bool CCImage::initWithString(
int nSize/* = 0*/)
{
bool bRet = false;
unsigned char * pImageData = 0;
do
{
CC_BREAK_IF(! pText);
@ -391,8 +390,8 @@ bool CCImage::initWithString(
SIZE size = {nWidth, nHeight};
CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask));
pImageData = new unsigned char[size.cx * size.cy * 4];
CC_BREAK_IF(! pImageData);
m_pData = new unsigned char[size.cx * size.cy * 4];
CC_BREAK_IF(! m_pData);
struct
{
@ -407,8 +406,6 @@ bool CCImage::initWithString(
m_nHeight = (short)size.cy;
m_bHasAlpha = true;
m_bPreMulti = false;
m_pData = pImageData;
pImageData = 0;
m_nBitsPerComponent = 8;
// copy pixed data
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0)

View File

@ -448,16 +448,16 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f
return false;
}
CCImage* pImage = new CCImage();
do
{
CCImage* pImage = new CCImage();
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
CC_SAFE_RELEASE(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
}

View File

@ -877,7 +877,8 @@ bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) {
if(!numKeyframes) return true;
CCBSequenceProperty* channel = new CCBSequenceProperty();
channel->autorelease();
for(int i = 0; i < numKeyframes; ++i) {
float time = readFloat();
@ -896,8 +897,8 @@ bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) {
CCBKeyframe* keyframe = new CCBKeyframe();
keyframe->setTime(time);
keyframe->setValue(value);
channel->getKeyframes()->addObject(keyframe);
keyframe->release();
}
seq->setSoundChannel(channel);

View File

@ -1,4 +1,5 @@
#include "TimelineCallbackTestLayer.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;
USING_NS_CC_EXT;
@ -10,6 +11,7 @@ TimelineCallbackTestLayer::TimelineCallbackTestLayer()
TimelineCallbackTestLayer::~TimelineCallbackTestLayer()
{
CC_SAFE_RELEASE(_helloLabel);
CocosDenshion::SimpleAudioEngine::end();
}
SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, const char * pSelectorName) {

View File

@ -1004,7 +1004,9 @@ void LabelTTFTest::updateAlignment()
{
m_plabel->removeFromParentAndCleanup(true);
}
CC_SAFE_RELEASE(m_plabel);
m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), "Marker Felt", 32,
blockSize, m_eHorizAlign, m_eVertAlign);
m_plabel->retain();