From Cedric Pinson, crash fix for osganimationtimeline that was caused by not checking if nathan.osg test file had be loaded or not.

This commit is contained in:
Robert Osfield
2009-07-16 11:52:18 +00:00
parent df14b9980a
commit 65f85fee6d

View File

@@ -1,5 +1,5 @@
/* -*-c++-*- /* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net> * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
* *
* This library is open source and may be redistributed and/or modified under * This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
@@ -157,22 +157,26 @@ struct ExampleTimelineUsage : public osgGA::GUIEventHandler
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
std::cerr << "This example works only with osgAnimation/nathan.osg" << std::endl; std::cerr << "This example works only with nathan.osg" << std::endl;
osg::ArgumentParser psr(&argc, argv); osg::ArgumentParser psr(&argc, argv);
osgViewer::Viewer viewer(psr); osgViewer::Viewer viewer(psr);
std::string file = "osgAnimation/nathan.osg"; std::string file = "nathan.osg";
if(argc >= 2) if(argc >= 2)
file = psr[1]; file = psr[1];
// replace the manager // replace the manager
osg::Group* root = dynamic_cast<osg::Group*>(osgDB::readNodeFile(file)); osg::Group* root = dynamic_cast<osg::Group*>(osgDB::readNodeFile(file));
if (!root) {
osg::notify(osg::FATAL) << "can't read file " << file << std::endl;
return 1;
}
osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(root->getUpdateCallback()); osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(root->getUpdateCallback());
if(!animationManager) if(!animationManager)
{ {
std::cerr << "Did not find AnimationManagerBase updateCallback needed to animate elements" << std::endl; osg::notify(osg::FATAL) << "Did not find AnimationManagerBase updateCallback needed to animate elements" << std::endl;
return 1; return 1;
} }