issue #129, add obj->release when obj is inserted into NSDictionary

This commit is contained in:
Walzer 2010-09-08 06:52:56 +00:00
parent 48859df034
commit cba41dc44b
2 changed files with 18 additions and 9 deletions

View File

@ -216,16 +216,17 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
CCX_SAFE_DELETE(image);// image->release(); CCX_SAFE_DELETE(image);// image->release();
if( texture ) if( texture )
{
m_pTextures->setObject(texture, fullpath); m_pTextures->setObject(texture, fullpath);
texture->autorelease();
}
else else
{
CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path); CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path);
}
texture->release();
} }
} }
m_pDictLock->unlock(); m_pDictLock->unlock();
return texture; return texture;
} }
@ -250,13 +251,16 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl
texture = new CCTexture2D(); texture = new CCTexture2D();
texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width); texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width);
if( texture ) if( texture )
{
m_pTextures->setObject(texture, temp); m_pTextures->setObject(texture, temp);
texture->autorelease();
}
else else
{
CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",path); CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",path);
}
CCX_SAFE_DELETE(data); CCX_SAFE_DELETE(data);
texture->autorelease();
return texture; return texture;
} }
@ -274,11 +278,15 @@ CCTexture2D * CCTextureCache::addPVRTCImage(const char* fileimage)
texture = new CCTexture2D(); texture = new CCTexture2D();
texture = texture->initWithPVRTCFile(fileimage); texture = texture->initWithPVRTCFile(fileimage);
if( texture ) if( texture )
{
m_pTextures-> setObject( texture, key); m_pTextures-> setObject( texture, key);
texture->autorelease();
}
else else
CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",fileimage); {
CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",fileimage);
}
texture->autorelease();
return texture; return texture;
} }
#endif #endif
@ -326,12 +334,12 @@ CCTexture2D* CCTextureCache::addUIImage(UIImage *image, const char *key)
if(texture) if(texture)
{ {
m_pTextures->setObject(texture, forKey); m_pTextures->setObject(texture, forKey);
texture->autorelease();
} }
else else
{ {
CCLOG("cocos2d: Couldn't add UIImage in CCTextureCache"); CCLOG("cocos2d: Couldn't add UIImage in CCTextureCache");
} }
texture->autorelease();
return texture; return texture;
} }

View File

@ -326,6 +326,7 @@ namespace cocos2d {
CCXStringToStringDictionary *dict = new CCXStringToStringDictionary(); CCXStringToStringDictionary *dict = new CCXStringToStringDictionary();
pTMXMapInfo->setParentGID(info->m_uFirstGid + atoi(valueForKey("id", attributeDict))); pTMXMapInfo->setParentGID(info->m_uFirstGid + atoi(valueForKey("id", attributeDict)));
pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID());
CCX_SAFE_RELEASE(dict);
pTMXMapInfo->setParentElement(TMXPropertyTile); pTMXMapInfo->setParentElement(TMXPropertyTile);