From a17f141e7dd70ea6e031b3fb5037f76d452b6903 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Thu, 10 Oct 2013 10:28:49 +0800 Subject: [PATCH] issues #2914:removeSpriteFramesFromFile() crashes if file doesn't exist --- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 945cd30f32..1d19773c60 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -344,7 +344,11 @@ void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); Dictionary* dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str()); - + if (dict == nullptr) + { + CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist); + return; + } removeSpriteFramesFromDictionary((Dictionary*)dict); // remove it from the cache