Some fixes detected by xcode analyze

This commit is contained in:
James Chen 2014-04-09 20:41:09 +08:00
parent 8fadeeb3e8
commit 61134426a8
8 changed files with 21 additions and 23 deletions

View File

@ -237,7 +237,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
bool existNewLetter = false; bool existNewLetter = false;
int bottomHeight = _commonLineHeight - _fontAscender; int bottomHeight = _commonLineHeight - _fontAscender;
float startX = _currentPageOrigX;
float startY = _currentPageOrigY; float startY = _currentPageOrigY;
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
@ -268,7 +268,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
auto data = _currentPageData + CacheTextureWidth * (int)startY; auto data = _currentPageData + CacheTextureWidth * (int)startY;
_atlasTextures[_currentPage]->updateWithData(data, 0, startY, _atlasTextures[_currentPage]->updateWithData(data, 0, startY,
CacheTextureWidth, CacheTextureHeight - startY); CacheTextureWidth, CacheTextureHeight - startY);
startX = 0.0f;
startY = 0.0f; startY = 0.0f;
_currentPageOrigY = 0; _currentPageOrigY = 0;

View File

@ -497,7 +497,7 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
{ {
long bitmap_y = y * bitmapWidth; long bitmap_y = y * bitmapWidth;
for (int x = 0; x < bitmapWidth; ++x) for (long x = 0; x < bitmapWidth; ++x)
{ {
/* Dual channel 16-bit output (more complicated, but good precision and range) */ /* Dual channel 16-bit output (more complicated, but good precision and range) */
/*int index = (iX + ( iY * destSize )) * 3; /*int index = (iX + ( iY * destSize )) * 3;

View File

@ -1081,15 +1081,17 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
if (_shadowEnabled && _shadowNode == nullptr) if (_shadowEnabled && _shadowNode == nullptr)
{ {
_shadowNode = Sprite::createWithTexture(_textSprite->getTexture()); _shadowNode = Sprite::createWithTexture(_textSprite->getTexture());
if (_shadowNode && _blendFuncDirty) if (_shadowNode)
{ {
_shadowNode->setBlendFunc(_blendFunc); if (_blendFuncDirty)
_shadowNode->setBlendFunc(_blendFunc);
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
Node::addChild(_shadowNode,0,Node::INVALID_TAG);
} }
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
Node::addChild(_shadowNode,0,Node::INVALID_TAG);
} }
if (_shadowNode) if (_shadowNode)
{ {
@ -1236,7 +1238,7 @@ void Label::computeStringNumLines()
{ {
int quantityOfLines = 1; int quantityOfLines = 1;
unsigned int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1; int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1;
if (stringLen < 1) if (stringLen < 1)
{ {
_currNumLines = stringLen; _currNumLines = stringLen;
@ -1244,7 +1246,7 @@ void Label::computeStringNumLines()
} }
// count number of lines // count number of lines
for (unsigned int i = 0; i < stringLen - 1; ++i) for (int i = 0; i < stringLen - 1; ++i)
{ {
if (_currentUTF16String[i] == '\n') if (_currentUTF16String[i] == '\n')
{ {

View File

@ -105,7 +105,7 @@ void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool par
kmGLPushMatrix(); kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform); kmGLLoadMatrix(&_modelViewTransform);
Director::Projection beforeProjectionType; Director::Projection beforeProjectionType = Director::Projection::DEFAULT;
if(_nodeGrid && _nodeGrid->isActive()) if(_nodeGrid && _nodeGrid->isActive())
{ {
beforeProjectionType = Director::getInstance()->getProjection(); beforeProjectionType = Director::getInstance()->getProjection();

View File

@ -483,6 +483,7 @@ bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
{ {
memset(tmpQuads+oldCapactiy, 0, (_capacity - oldCapactiy)*sizeof(_quads[0]) ); memset(tmpQuads+oldCapactiy, 0, (_capacity - oldCapactiy)*sizeof(_quads[0]) );
} }
_quads = nullptr;
} }
if (_indices == nullptr) if (_indices == nullptr)
@ -492,7 +493,6 @@ bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
{ {
memset( tmpIndices, 0, _capacity * 6 * sizeof(_indices[0]) ); memset( tmpIndices, 0, _capacity * 6 * sizeof(_indices[0]) );
} }
} }
else else
{ {
@ -501,6 +501,7 @@ bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
{ {
memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) ); memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) );
} }
_indices = nullptr;
} }
if( ! ( tmpQuads && tmpIndices) ) { if( ! ( tmpQuads && tmpIndices) ) {

View File

@ -250,7 +250,6 @@ void GLViewProtocol::handleTouchesBegin(int num, intptr_t ids[], float xs[], flo
y = ys[i]; y = ys[i];
auto iter = g_touchIdReorderMap.find(id); auto iter = g_touchIdReorderMap.find(id);
unusedIndex = 0;
// it is a new touch // it is a new touch
if (iter == g_touchIdReorderMap.end()) if (iter == g_touchIdReorderMap.end())

View File

@ -1552,7 +1552,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
} }
else else
{ {
if (tgaData->imageData != nullptr) if (tgaData && tgaData->imageData != nullptr)
{ {
free(tgaData->imageData); free(tgaData->imageData);
_data = nullptr; _data = nullptr;

View File

@ -1003,7 +1003,7 @@ const Rect& Layout::getClippingRect()
float scissorHeight = _size.height*t.d; float scissorHeight = _size.height*t.d;
Rect parentClippingRect; Rect parentClippingRect;
Layout* parent = this; Layout* parent = this;
bool firstClippingParentFounded = false;
while (parent) while (parent)
{ {
parent = dynamic_cast<Layout*>(parent->getParent()); parent = dynamic_cast<Layout*>(parent->getParent());
@ -1011,12 +1011,8 @@ const Rect& Layout::getClippingRect()
{ {
if (parent->isClippingEnabled()) if (parent->isClippingEnabled())
{ {
if (!firstClippingParentFounded) _clippingParent = parent;
{ break;
_clippingParent = parent;
firstClippingParentFounded = true;
break;
}
} }
} }
} }