Merge pull request #11105 from pipu/TextAtlas_parse_avoid_crash

Avoid crash during parse TextAtlas.
This commit is contained in:
minggo 2015-03-25 13:36:28 +08:00
commit 326233ab02
1 changed files with 31 additions and 8 deletions

View File

@ -247,19 +247,42 @@ namespace cocostudio
case 0:
{
const char* cmfPath = cmftDic->path()->c_str();
std::string stringValue = options->stringValue()->c_str();
int itemWidth = options->itemWidth();
int itemHeight = options->itemHeight();
labelAtlas->setProperty(stringValue,
cmfPath,
itemWidth,
itemHeight,
options->startCharMap()->c_str());
bool fileExist = false;
std::string errorFilePath = "";
if (FileUtils::getInstance()->isFileExist(cmfPath))
{
fileExist = true;
std::string stringValue = options->stringValue()->c_str();
int itemWidth = options->itemWidth();
int itemHeight = options->itemHeight();
labelAtlas->setProperty(stringValue,
cmfPath,
itemWidth,
itemHeight,
options->startCharMap()->c_str());
}
else
{
errorFilePath = cmfPath;
fileExist = false;
}
if (!fileExist)
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
labelAtlas->addChild(label);
}
break;
}
case 1:
CCLOG("Wrong res type of LabelAtlas!");
break;
default:
break;
}