Permalink
Browse files

Fixed crash when no CameraManipulator is assigned to the viewer

  • Loading branch information...
1 parent 079de03 commit ff40db5b5d3761ecfba35f76eed2675a9ac2ed4d @osg-training-guest osg-training-guest committed Nov 30, 2012
Showing with 29 additions and 18 deletions.
  1. +7 −2 src/osgPlugins/p3d/ReaderWriterP3D.cpp
  2. +22 −16 src/osgPresentation/SlideEventHandler.cpp
@@ -402,19 +402,20 @@ bool ReaderWriterP3DXML::getKeyProperty(osgDB::XmlNode*cur, const char* token, i
{
std::istringstream iss(itr->second);
iss>>std::hex>>value;
+ OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() hex result = "<<value<<std::endl;
return true;
}
else if (itr->second.size()>1 && (itr->second[0]>='0' && itr->second[0]<='9'))
{
std::istringstream iss(itr->second);
iss>>value;
- OSG_NOTICE<<" numeric result = "<<value<<std::endl;
+ OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() numeric result = "<<value<<std::endl;
return true;
}
else
{
value = itr->second[0];
- OSG_NOTICE<<" alphanumeric result = "<<value<<std::endl;
+ OSG_NOTICE<<"ReaderWriterP3DXML::getKeyProperty() alphanumeric result = "<<value<<std::endl;
return true;
}
}
@@ -1533,6 +1534,10 @@ void ReaderWriterP3DXML::parseLayer(osgPresentation::SlideShowConstructor& const
constructor.keyEventOperation(osgPresentation::SlideShowConstructor::CURRENT_LAYER, key, osgPresentation::JUMP, jumpData);
}
+ else
+ {
+ OSG_NOTICE<<"key_to_jump failed."<<std::endl;
+ }
}
else if (cur->name == "newline")
@@ -1244,10 +1244,13 @@ bool SlideEventHandler::selectSlide(int slideNum,int layerNum)
// refersh the viewer.
//_viewer->getKeySwitchMatrixManipulator()->setMinimumDistance(0.001);
- _viewer->getCameraManipulator()->setNode(_slideSwitch.get());
-
- _viewer->computeActiveCoordinateSystemNodePath();
+ if (_viewer->getCameraManipulator())
+ {
+ _viewer->getCameraManipulator()->setNode(_slideSwitch.get());
+ _viewer->computeActiveCoordinateSystemNodePath();
+ }
+
// resetUpdateCallbacks(ALL_OBJECTS);
bool _useSlideFilePaths = false;
@@ -1387,22 +1390,25 @@ bool SlideEventHandler::home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAd
osg::Node* node = _viewer->getSceneData();
if (node) node->accept(fhpv);
- if (fhpv._homePosition.valid())
+ if (_viewer->getCameraManipulator())
{
- OSG_INFO<<"Doing home for stored home position."<<std::endl;
+ if (fhpv._homePosition.valid())
+ {
+ OSG_INFO<<"Doing home for stored home position."<<std::endl;
- _viewer->getCameraManipulator()->setAutoComputeHomePosition(false);
- _viewer->getCameraManipulator()->setHomePosition(
- fhpv._homePosition->eye,
- fhpv._homePosition->center,
- fhpv._homePosition->up);
- }
- else
- {
- _viewer->getCameraManipulator()->setAutoComputeHomePosition(true);
+ _viewer->getCameraManipulator()->setAutoComputeHomePosition(false);
+ _viewer->getCameraManipulator()->setHomePosition(
+ fhpv._homePosition->eye,
+ fhpv._homePosition->center,
+ fhpv._homePosition->up);
+ }
+ else
+ {
+ _viewer->getCameraManipulator()->setAutoComputeHomePosition(true);
+ }
+ _viewer->getCameraManipulator()->home(ea,aa);
}
- _viewer->getCameraManipulator()->home(ea,aa);
-
+
return true;
}

0 comments on commit ff40db5

Please sign in to comment.