handling NULL pointer

This commit is contained in:
AlessandroSigna 2016-01-07 10:11:02 -08:00
parent 7b74f7407a
commit 18390c87da

View file

@ -172,7 +172,10 @@ void OverlayPanel::applyTransformTo(Transform& transform, bool force) {
} else if (!_anchorPositionBindEntity.isNull()) {
EntityTreePointer entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
entityTree->withReadLock([&] {
transform.setTranslation(entityTree->findEntityByID(_anchorPositionBindEntity)->getPosition());
EntityItemPointer foundEntity = entityTree->findEntityByID(_anchorPositionBindEntity);
if (foundEntity != NULL) {
transform.setTranslation(foundEntity->getPosition());
}
});
} else {
transform.setTranslation(getAnchorPosition());
@ -184,7 +187,10 @@ void OverlayPanel::applyTransformTo(Transform& transform, bool force) {
} else if (!_anchorRotationBindEntity.isNull()) {
EntityTreePointer entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
entityTree->withReadLock([&] {
transform.setRotation(entityTree->findEntityByID(_anchorRotationBindEntity)->getRotation());
EntityItemPointer foundEntity = entityTree->findEntityByID(_anchorRotationBindEntity);
if (foundEntity != NULL) {
transform.setRotation(foundEntity->getRotation());
}
});
} else {
transform.setRotation(getAnchorRotation());