mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:21:32 +02:00
Merge pull request #8791 from hyperlogic/bug-fix/avatar-hold-action-deadlock-fix
Deadlock fix in avatar grab action.
This commit is contained in:
commit
7ec1e05165
1 changed files with 5 additions and 4 deletions
|
@ -2283,12 +2283,13 @@ void MyAvatar::updateHoldActions(const AnimPose& prePhysicsPose, const AnimPose&
|
||||||
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
||||||
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
EntityTreePointer entityTree = entityTreeRenderer ? entityTreeRenderer->getTree() : nullptr;
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
// to prevent actions from adding or removing themselves from the _holdActions vector
|
|
||||||
// while we are iterating, we need to enter a critical section.
|
|
||||||
std::lock_guard<std::mutex> guard(_holdActionsMutex);
|
|
||||||
|
|
||||||
// lateAvatarUpdate will modify entity position & orientation, so we need an entity write lock
|
// lateAvatarUpdate will modify entity position & orientation, so we need an entity write lock
|
||||||
entityTree->withWriteLock([&] {
|
entityTree->withWriteLock([&] {
|
||||||
|
|
||||||
|
// to prevent actions from adding or removing themselves from the _holdActions vector
|
||||||
|
// while we are iterating, we need to enter a critical section.
|
||||||
|
std::lock_guard<std::mutex> guard(_holdActionsMutex);
|
||||||
|
|
||||||
for (auto& holdAction : _holdActions) {
|
for (auto& holdAction : _holdActions) {
|
||||||
holdAction->lateAvatarUpdate(prePhysicsPose, postUpdatePose);
|
holdAction->lateAvatarUpdate(prePhysicsPose, postUpdatePose);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue