Ensure the tree lock is always taken before the simulation lock

This commit is contained in:
Atlante45 2018-04-24 13:43:09 -07:00
parent 236e75b6c6
commit d82333534c
2 changed files with 10 additions and 8 deletions

View file

@ -380,10 +380,15 @@ void EntityServer::trackSend(const QUuid& dataID, quint64 dataLastEdited, const
} }
void EntityServer::trackViewerGone(const QUuid& sessionID) { void EntityServer::trackViewerGone(const QUuid& sessionID) {
QWriteLocker locker(&_viewerSendingStatsLock); {
_viewerSendingStats.remove(sessionID); QWriteLocker locker(&_viewerSendingStatsLock);
_viewerSendingStats.remove(sessionID);
}
if (_entitySimulation) { if (_entitySimulation) {
_entitySimulation->clearOwnership(sessionID); _tree->withReadLock([&] {
_entitySimulation->clearOwnership(sessionID);
});
} }
} }

View file

@ -38,11 +38,8 @@ void SimpleEntitySimulation::clearOwnership(const QUuid& ownerID) {
entity->clearSimulationOwnership(); entity->clearSimulationOwnership();
entity->markAsChangedOnServer(); entity->markAsChangedOnServer();
if (auto element = entity->getElement()) { if (auto element = entity->getElement()) {
auto tree = getEntityTree(); DirtyOctreeElementOperator op(element);
tree->withReadLock([&] { getEntityTree()->recurseTreeWithOperator(&op);
DirtyOctreeElementOperator op(element);
tree->recurseTreeWithOperator(&op);
});
} }
} else { } else {
++itemItr; ++itemItr;