From cba41dc44b75df97e2d2900eca8dc0fc1ae8a079 Mon Sep 17 00:00:00 2001 From: Walzer Date: Wed, 8 Sep 2010 06:52:56 +0000 Subject: [PATCH] issue #129, add obj->release when obj is inserted into NSDictionary --- cocos2dx/textures/CCTextureCache.cpp | 26 ++++++++++++------- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 25c5b5fde7..4a0bdec294 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -216,16 +216,17 @@ CCTexture2D * CCTextureCache::addImage(const char * path) CCX_SAFE_DELETE(image);// image->release(); if( texture ) + { m_pTextures->setObject(texture, fullpath); + texture->autorelease(); + } else + { CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path); - - texture->release(); + } } } - m_pDictLock->unlock(); - return texture; } @@ -250,13 +251,16 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl texture = new CCTexture2D(); texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width); if( texture ) + { m_pTextures->setObject(texture, temp); + texture->autorelease(); + } else + { CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",path); - + } CCX_SAFE_DELETE(data); - texture->autorelease(); return texture; } @@ -274,11 +278,15 @@ CCTexture2D * CCTextureCache::addPVRTCImage(const char* fileimage) texture = new CCTexture2D(); texture = texture->initWithPVRTCFile(fileimage); if( texture ) + { m_pTextures-> setObject( texture, key); + texture->autorelease(); + } 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; } #endif @@ -326,12 +334,12 @@ CCTexture2D* CCTextureCache::addUIImage(UIImage *image, const char *key) if(texture) { m_pTextures->setObject(texture, forKey); + texture->autorelease(); } else { CCLOG("cocos2d: Couldn't add UIImage in CCTextureCache"); } - texture->autorelease(); return texture; } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index c6752a72d0..8356cc3d0e 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -326,6 +326,7 @@ namespace cocos2d { CCXStringToStringDictionary *dict = new CCXStringToStringDictionary(); pTMXMapInfo->setParentGID(info->m_uFirstGid + atoi(valueForKey("id", attributeDict))); pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID()); + CCX_SAFE_RELEASE(dict); pTMXMapInfo->setParentElement(TMXPropertyTile);