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

View File

@ -497,7 +497,7 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
{
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) */
/*int index = (iX + ( iY * destSize )) * 3;

View File

@ -1081,15 +1081,17 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
if (_shadowEnabled && _shadowNode == nullptr)
{
_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)
{
@ -1236,7 +1238,7 @@ void Label::computeStringNumLines()
{
int quantityOfLines = 1;
unsigned int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1;
int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1;
if (stringLen < 1)
{
_currNumLines = stringLen;
@ -1244,7 +1246,7 @@ void Label::computeStringNumLines()
}
// 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')
{

View File

@ -105,7 +105,7 @@ void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool par
kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform);
Director::Projection beforeProjectionType;
Director::Projection beforeProjectionType = Director::Projection::DEFAULT;
if(_nodeGrid && _nodeGrid->isActive())
{
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]) );
}
_quads = nullptr;
}
if (_indices == nullptr)
@ -492,7 +493,6 @@ bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
{
memset( tmpIndices, 0, _capacity * 6 * sizeof(_indices[0]) );
}
}
else
{
@ -501,6 +501,7 @@ bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
{
memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) );
}
_indices = nullptr;
}
if( ! ( tmpQuads && tmpIndices) ) {

View File

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

View File

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

View File

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