Projects > cpp > Issues > Bug #1395

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

Create Issue on Github

CCTextureCache::addImage ignores error in CCTexture2D::initWithImage

Bug #1395 [Closed]
walzer@cocos2d-x.org 2012-07-14 02:59 . Updated almost 11 years ago

Reported at https://github.com/cocos2d/cocos2d-x/issues/1095 by mfellner.

In CCTextureCache.cpp:446 (addImage(const char * path)) there is the following problem:

texture = new CCTexture2D();
texture->initWithImage(ℑ, resolution); // returns a boolean

if( texture ) // should check result of previous method call
{
    // ...
    // this is executed even if there was an error in initWithImage
    texture->release(); // double release will finally result in an error
}
else
{
    CCLOG("cocos2d: Couldn't add image:%s in CCTextureCache", path);
}

And in CCTexture2D.cpp:272 (initWithImage(CCImage * uiImage, ccResolutionType resolution)):

if (imageWidth > maxTextureSize || imageHeight > maxTextureSize) 
 {
    CCLOG("cocos2d: WARNING: Image (%u x %u) is bigger than the supported %u x %u", imageWidth, imageHeight, maxTextureSize, maxTextureSize);
    this->release();
    return NULL; // should return false instead
}
zhangxm 2012-07-17 06:31
  • Status changed from New to Closed

Atom PDF

Status:Closed
Start date:2012-07-14
Priority:Normal
Due date:
Assignee:walzer@cocos2d-x.org
% Done:

0%

Category:all
Target version:cocos2d-2.0-x-2.0.2