Bug #1395

CCTextureCache::addImage ignores error in CCTexture2D::initWithImage

Added by Zhe Wang 10 months ago. Updated 10 months ago.

Status:Closed Start date:2012-07-14
Priority:Normal Due date:
Assignee:Zhe Wang % Done:

0%

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

Description

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(&image, 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
}

History

Updated by Minggo Zhang 10 months ago

  • Status changed from New to Closed

Also available in: Atom PDF