Projects > cpp > Issues > Bug #911

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

TextureCache::addUIImage cannot create texture when key is null, but the document said it can

Bug #911 [Closed]
walzer@cocos2d-x.org 2011-12-12 07:09 . Updated over 4 years ago

reported at http://www.cocos2d-x.org/boards/6/topics/5968
I guess we added CCAssert too more conditions, or the document must be corrected.

johan_viktorsson 2011-12-12 07:58

It wasn’t as simple as just fixing the Assert, posting the complete (patched)
method here: (key is implicitely converted to a string through the string(char const* str) constructor, so I took the liberty to remove the forKey variable, all checks need to be performed on the key variable anyways).

CCTexture2D* CCTextureCache::addUIImage(CCImage image, const charkey)
{
CCAssert(image != NULL, “TextureCache: image MUST not be nill”);

CCTexture2D * texture = NULL;
m_pDictLock~~>lock;
do
{
// If key is nil, then create a new texture each time
if))
{
break;
}
// prevents overloading the autorelease pool
texture = new CCTexture2D;
texture~~>initWithImage(image);

if(texture)
{
if(key != 0) {
m_pTextures~~>setObject;
}
texture~~>autorelease();
}
else
{
CCLOG ("cocos2d: Couldn't add UIImage in CCTextureCache");
}

} while (0);

m_pDictLock->unlock();

return texture;
}

zhangxm 2011-12-22 00:30
  • Assignee set to zhangxm
zhangxm 2011-12-22 00:40
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:7770b69b180aa1f65be021d43d3abc6543ae3548.

zhangxm 2011-12-22 00:40

Applied in changeset commit:bd9950ccf82ba37f2c62ceb6c5a99e9f83ed9766.

zhangxm 2011-12-28 19:19
  • Status changed from Resolved to Closed
walzer@cocos2d-x.org 2012-05-25 08:00
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (cocos2d-1.0.1-x-0.11.0)

Atom PDF

Status:Closed
Start date:2011-12-12
Priority:Normal
Due date:
Assignee:zhangxm
% Done:

100%

Category:-
Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.