diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index c683a2d3d0..6aa36098a3 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -214,6 +214,16 @@ CCTexture2D * CCTextureCache::addImage(const char * path) texture = new CCTexture2D(); texture->initWithImage(image); CCX_SAFE_DELETE(image);// image->release(); + + if( texture ) + { + m_pTextures->setObject(texture, fullpath); + texture->release(); + } + else + { + CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path); + } } else { @@ -237,7 +247,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) if( texture ) { m_pTextures->setObject(texture, fullpath); - texture->autorelease(); + texture->release(); } else {