From f0dba9e76691456da79dffc724bf70fb658e4119 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 12 Oct 2016 16:29:05 -0700 Subject: [PATCH] Prevent crash on exit. If you or another user begins to near-grab an object while you exit the application, you might run into this crash. The PhysicalEntitySimulation has a list of AvatarHoldActions shared_ptr's. When it is destroyed, via the Application destructor, it will release these pointers. This in turn will invoke a AvatarHoldAction destructor, which attempts to reference the AvatarManager via the DependencyManager. However at this point the AvatarManager has already been destroyed, leading to a null dereference. The fix is to check the AvatarManager pointer first. --- interface/src/avatar/AvatarActionHold.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index e85cb8913c..85ff485d7a 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -37,9 +37,13 @@ AvatarActionHold::AvatarActionHold(const QUuid& id, EntityItemPointer ownerEntit } AvatarActionHold::~AvatarActionHold() { - auto myAvatar = DependencyManager::get()->getMyAvatar(); - if (myAvatar) { - myAvatar->removeHoldAction(this); + // Sometimes actions are destroyed after the AvatarManager is destroyed by the Application. + auto avatarManager = DependencyManager::get(); + if (avatarManager) { + auto myAvatar = avatarManager->getMyAvatar(); + if (myAvatar) { + myAvatar->removeHoldAction(this); + } } #if WANT_DEBUG