Fix unused variable warnings when compiling release mode

This commit is contained in:
mogemimi 2016-06-17 14:13:35 +09:00
parent 49e24eb0ba
commit f0028e5459
2 changed files with 14 additions and 1 deletions

View File

@ -253,7 +253,6 @@ std::vector<cocos2d::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2
int curx = startx; int curx = startx;
int cury = starty; int cury = starty;
unsigned int count = 0; unsigned int count = 0;
unsigned int totalPixel = _width*_height;
bool problem = false; bool problem = false;
std::vector<int> case9s; std::vector<int> case9s;
std::vector<int> case6s; std::vector<int> case6s;
@ -408,7 +407,11 @@ std::vector<cocos2d::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2
prevx = stepx; prevx = stepx;
prevy = stepy; prevy = stepy;
problem = false; problem = false;
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
const auto totalPixel = _width * _height;
CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position"); CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position");
#endif
} while(curx != startx || cury != starty); } while(curx != startx || cury != starty);
return _points; return _points;
} }

View File

@ -326,6 +326,11 @@ Sprite* createSpriteFromBase64Cached(const char* base64String, const char* key)
CCASSERT(imageResult, "Failed to create image from base64!"); CCASSERT(imageResult, "Failed to create image from base64!");
free(decoded); free(decoded);
if (!imageResult) {
CC_SAFE_RELEASE_NULL(image);
return nullptr;
}
texture = Director::getInstance()->getTextureCache()->addImage(image, key); texture = Director::getInstance()->getTextureCache()->addImage(image, key);
image->release(); image->release();
} }
@ -345,6 +350,11 @@ Sprite* createSpriteFromBase64(const char* base64String)
CCASSERT(imageResult, "Failed to create image from base64!"); CCASSERT(imageResult, "Failed to create image from base64!");
free(decoded); free(decoded);
if (!imageResult) {
CC_SAFE_RELEASE_NULL(image);
return nullptr;
}
Texture2D *texture = new (std::nothrow) Texture2D(); Texture2D *texture = new (std::nothrow) Texture2D();
texture->initWithImage(image); texture->initWithImage(image);
texture->setAliasTexParameters(); texture->setAliasTexParameters();