diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 3c1f7ae0d229..4cd1e3c057f3 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -399,11 +399,14 @@ void Sprite::setTexture(Texture2D *texture) } } - if ((_renderMode != RenderMode::QUAD_BATCHNODE) && (_texture != texture)) + if (_renderMode != RenderMode::QUAD_BATCHNODE) { - CC_SAFE_RETAIN(texture); - CC_SAFE_RELEASE(_texture); - _texture = texture; + if (_texture != texture) + { + CC_SAFE_RETAIN(texture); + CC_SAFE_RELEASE(_texture); + _texture = texture; + } updateBlendFunc(); } }