Merge pull request #9555 from huffman/fix/entity-is-child-of-crash

Fix Entities.isChildOfParent crashing if given unknown ID
This commit is contained in:
Brad Hefta-Gaub 2017-01-31 08:42:45 -08:00 committed by GitHub
commit 5287c94786

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;