Merge pull request #12279 from druiz17/fix-parenting-crash

fix entity parenting crash
This commit is contained in:
John Conklin II 2018-01-31 09:32:52 -08:00 committed by GitHub
commit ece72501b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1679,14 +1679,17 @@ void EntityTree::entityChanged(EntityItemPointer entity) {
}
}
void EntityTree::fixupNeedsParentFixups() {
PROFILE_RANGE(simulation_physics, "FixupParents");
MovingEntitiesOperator moveOperator;
QVector<EntityItemWeakPointer> entitiesToFixup;
{
QWriteLocker locker(&_needsParentFixupLock);
entitiesToFixup = _needsParentFixup;
_needsParentFixup.clear();
}
QWriteLocker locker(&_needsParentFixupLock);
QMutableVectorIterator<EntityItemWeakPointer> iter(_needsParentFixup);
QMutableVectorIterator<EntityItemWeakPointer> iter(entitiesToFixup);
while (iter.hasNext()) {
EntityItemWeakPointer entityWP = iter.next();
EntityItemPointer entity = entityWP.lock();
@ -1749,6 +1752,12 @@ void EntityTree::fixupNeedsParentFixups() {
PerformanceTimer perfTimer("recurseTreeWithOperator");
recurseTreeWithOperator(&moveOperator);
}
{
QWriteLocker locker(&_needsParentFixupLock);
// add back the entities that did not get fixup
_needsParentFixup.append(entitiesToFixup);
}
}
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {