Fix Entities.isChildOfParent crashing if given unknown ID

If an entity was not in the local tree a null deref crash would occur.
This commit makes sure the entity pointer is checked for null before it is used.
This commit is contained in:
Ryan Huffman 2017-01-30 13:37:00 -08:00
parent ae8d0d1948
commit e58c9326a0

View file

@ -1366,12 +1366,14 @@ bool EntityScriptingInterface::isChildOfParent(QUuid childID, QUuid parentID) {
_entityTree->withReadLock([&] {
EntityItemPointer parent = _entityTree->findEntityByEntityItemID(parentID);
parent->forEachDescendant([&](SpatiallyNestablePointer descendant) {
if(descendant->getID() == childID) {
isChild = true;
return;
}
});
if (parent) {
parent->forEachDescendant([&](SpatiallyNestablePointer descendant) {
if (descendant->getID() == childID) {
isChild = true;
return;
}
});
}
});
return isChild;