Merge pull request #14056 from Dimon4eg/fix-crash-if-csb-file-is-missing

fix crash if csb file is broken
This commit is contained in:
pandamicro 2015-10-08 11:50:40 +08:00
commit 2d73bbd9d4
1 changed files with 13 additions and 3 deletions

View File

@ -950,6 +950,13 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName, const ccNod
Data buf = FileUtils::getInstance()->getDataFromFile(fullPath);
if (buf.isNull())
{
CCLOG("CSLoader::nodeWithFlatBuffersFile - failed read file: %s", fileName.c_str());
CC_ASSERT(false);
return nullptr;
}
auto csparsebinary = GetCSParseBinary(buf.getBytes());
@ -972,7 +979,7 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName, const ccNod
// decode plist
auto textures = csparsebinary->textures();
int textureSize = csparsebinary->textures()->size();
int textureSize = textures->size();
CCLOG("textureSize = %d", textureSize);
for (int i = 0; i < textureSize; ++i)
{
@ -991,6 +998,9 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const ccNodeLoadCallback &callback)
{
if (nodetree == nullptr)
return nullptr;
{
Node* node = nullptr;