Merge pull request #10219 from geron-cn/fixProjectNodeLoader

fix bug: fix crash when lack of projectnode file
This commit is contained in:
minggo 2015-01-27 13:41:27 +08:00
commit 434c0baba4
2 changed files with 29 additions and 17 deletions

View File

@ -481,6 +481,9 @@ InnerActionFrame::InnerActionFrame()
void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
auto innerActiontimeline = static_cast<ActionTimeline*>(_node->getActionByTag(_node->getTag()));
if( nullptr == innerActiontimeline)
return;
if (InnerActionType::SingleFrame == _innerActionType)
{
innerActiontimeline->gotoFrameAndPause(_singleFrameIndex);

View File

@ -833,20 +833,24 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
std::string filePath = projectNodeOptions->fileName()->c_str();
CCLOG("filePath = %s", filePath.c_str());
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
node = createNodeWithFlatBuffersFile(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, options->data());
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
}
}
else if (classname == "SimpleAudio")
{
@ -1164,19 +1168,24 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
std::string filePath = projectNodeOptions->fileName()->c_str();
CCLOG("filePath = %s", filePath.c_str());
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
node = createNodeWithFlatBuffersForSimulator(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
node = createNodeWithFlatBuffersFile(filePath);
action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, options->data());
if (action)
{
node->runAction(action);
action->gotoFrameAndPause(0);
}
}
}
else if (classname == "SimpleAudio")
{
node = Node::create();