Fix unprotected tree traversals
Showing the changes to libraries/entities/src/SimpleEntitySimulation.cpp (1 of 4 files). Show all
Unified · Split
| @@ -37,8 +37,13 @@ void SimpleEntitySimulation::clearOwnership(const QUuid& ownerID) { · 36 unmodified lines | |||
| 37 | // remove ownership and dirty all the tree elements that contain the it | 37 | // remove ownership and dirty all the tree elements that contain the it |
| 38 | entity->clearSimulationOwnership(); | 38 | entity->clearSimulationOwnership(); |
| 39 | entity->markAsChangedOnServer(); | 39 | entity->markAsChangedOnServer(); |
| 40 | DirtyOctreeElementOperator op(entity->getElement()); | 40 | if (auto element = entity->getElement()) { |
| 41 | getEntityTree()->recurseTreeWithOperator(&op); | 41 | auto tree = getEntityTree(); |
| 42 | tree->withReadLock([&] { | ||
| 43 | DirtyOctreeElementOperator op(element); | ||
| 44 | tree->recurseTreeWithOperator(&op); | ||
| 45 | }); | ||
| 46 | } | ||
| 42 | } else { | 47 | } else { |
| 43 | ++itemItr; | 48 | ++itemItr; |
| 44 | } | 49 | } |