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([&] { _entityTree->withReadLock([&] {
EntityItemPointer parent = _entityTree->findEntityByEntityItemID(parentID); EntityItemPointer parent = _entityTree->findEntityByEntityItemID(parentID);
parent->forEachDescendant([&](SpatiallyNestablePointer descendant) { if (parent) {
if(descendant->getID() == childID) { parent->forEachDescendant([&](SpatiallyNestablePointer descendant) {
isChild = true; if (descendant->getID() == childID) {
return; isChild = true;
} return;
}); }
});
}
}); });
return isChild; return isChild;