Merge pull request #13527 from pandamicro/reader

Fix skybox parser crash with inexistent files
This commit is contained in:
pandamicro 2015-08-24 10:16:28 +08:00
commit 50c8855399
2 changed files with 18 additions and 2 deletions

View File

@ -385,9 +385,17 @@ namespace cocostudio
std::string downFileData = options->downFileData()->path()->c_str(); std::string downFileData = options->downFileData()->path()->c_str();
std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string forwardFileData = options->forwardFileData()->path()->c_str();
std::string backFileData = options->backFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str();
FileUtils *fileUtils = FileUtils::getInstance();
if (leftFileData.empty() || rightFileData.empty() || upFileData.empty() || downFileData.empty() || forwardFileData.empty() || backFileData.empty()) if (!fileUtils->isFileExist(leftFileData)
|| !fileUtils->isFileExist(rightFileData)
|| !fileUtils->isFileExist(upFileData)
|| !fileUtils->isFileExist(downFileData)
|| !fileUtils->isFileExist(forwardFileData)
|| !fileUtils->isFileExist(backFileData))
{
return; return;
}
Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData); Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData);
unsigned short cameraFlag = 1 << 10; unsigned short cameraFlag = 1 << 10;
childBox->setCameraMask(cameraFlag); childBox->setCameraMask(cameraFlag);

View File

@ -429,9 +429,17 @@ namespace cocostudio
std::string downFileData = options->downFileData()->path()->c_str(); std::string downFileData = options->downFileData()->path()->c_str();
std::string forwardFileData = options->forwardFileData()->path()->c_str(); std::string forwardFileData = options->forwardFileData()->path()->c_str();
std::string backFileData = options->backFileData()->path()->c_str(); std::string backFileData = options->backFileData()->path()->c_str();
FileUtils *fileUtils = FileUtils::getInstance();
if (leftFileData.empty() || rightFileData.empty() || upFileData.empty() || downFileData.empty() || forwardFileData.empty() || backFileData.empty()) if (!fileUtils->isFileExist(leftFileData)
|| !fileUtils->isFileExist(rightFileData)
|| !fileUtils->isFileExist(upFileData)
|| !fileUtils->isFileExist(downFileData)
|| !fileUtils->isFileExist(forwardFileData)
|| !fileUtils->isFileExist(backFileData))
{
return; return;
}
Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData); Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData);
childBox->setCameraMask(cameraFlag); childBox->setCameraMask(cameraFlag);
node->addChild(childBox, 0, "_innerSkyBox"); node->addChild(childBox, 0, "_innerSkyBox");