mirror of https://github.com/axmolengine/axmol.git
Merge pull request #11105 from pipu/TextAtlas_parse_avoid_crash
Avoid crash during parse TextAtlas.
This commit is contained in:
commit
326233ab02
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue