Guard against potential nullpointer dereferencing

This commit is contained in:
Emil Axelsson
2019-02-22 17:58:08 +01:00
parent c44290fe1f
commit b5eb41e27f
3 changed files with 23 additions and 2 deletions
+13 -1
View File
@@ -1039,6 +1039,9 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
const int action = interpretInteraction(list, lastProcessed);
const SceneGraphNode* anchor =
global::navigationHandler.orbitalNavigator().anchorNode();
if (!anchor) {
return;
}
#ifdef TOUCH_DEBUG_PROPERTIES
const std::map<int, std::string> interactionNames = {
@@ -1223,6 +1226,9 @@ double TouchInteraction::computeConstTimeDecayCoefficient(double velocity) {
double TouchInteraction::computeTapZoomDistance(double zoomGain) {
const SceneGraphNode* anchor =
global::navigationHandler.orbitalNavigator().anchorNode();
if (!anchor) {
return 0.0;
}
double dist = glm::distance(
_camera->positionVec3(),
@@ -1520,7 +1526,13 @@ void TouchInteraction::setCamera(Camera* camera) {
_camera = camera;
}
void TouchInteraction::setFocusNode(const SceneGraphNode* focusNode) {
global::navigationHandler.orbitalNavigator().setAnchorNode(focusNode->identifier());
if (focusNode) {
global::navigationHandler.orbitalNavigator().setAnchorNode(
focusNode->identifier()
);
} else {
global::navigationHandler.orbitalNavigator().setAnchorNode("");
}
}
void FrameTimeAverage::updateWithNewFrame(double sample) {