mirror of https://github.com/axmolengine/axmol.git
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:
commit
2d73bbd9d4
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue