From d5125ae179b28c2d0d07a453e3d1d97e93b9d332 Mon Sep 17 00:00:00 2001 From: StarWing Date: Thu, 27 Nov 2014 21:15:09 +0800 Subject: [PATCH] nullptr check when Sprite::setTexture with non-exists file --- cocos/2d/CCSprite.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 19378ea2da..34653d36b3 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -308,7 +308,8 @@ void Sprite::setTexture(const std::string &filename) setTexture(texture); Rect rect = Rect::ZERO; - rect.size = texture->getContentSize(); + if (texture) + rect.size = texture->getContentSize(); setTextureRect(rect); }