From 1804422df0d2d622374006818d3d66356e146ff2 Mon Sep 17 00:00:00 2001 From: amantley Date: Wed, 27 Jun 2018 11:15:33 -0700 Subject: [PATCH] remove orb in the otherAvatar destructor, and check _otherAvatarOrbMeshPlaceholder pointer before updating the position --- interface/src/avatar/OtherAvatar.cpp | 8 +++++++- interface/src/avatar/OtherAvatar.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index 7ef4269b96..5e51658128 100644 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -22,6 +22,10 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { createOrb(); } +OtherAvatar::~OtherAvatar() { + removeOrb(); +} + void OtherAvatar::removeOrb() { if (qApp->getOverlays().isAddedOverlay(_otherAvatarOrbMeshPlaceholderID)) { qApp->getOverlays().deleteOverlay(_otherAvatarOrbMeshPlaceholderID); @@ -29,7 +33,9 @@ void OtherAvatar::removeOrb() { } void OtherAvatar::updateOrbPosition() { - _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); + if (_otherAvatarOrbMeshPlaceholder != nullptr) { + _otherAvatarOrbMeshPlaceholder->setWorldPosition(getHead()->getPosition()); + } } void OtherAvatar::createOrb() { diff --git a/interface/src/avatar/OtherAvatar.h b/interface/src/avatar/OtherAvatar.h index 483f400bed..e6f5b9c433 100644 --- a/interface/src/avatar/OtherAvatar.h +++ b/interface/src/avatar/OtherAvatar.h @@ -17,6 +17,8 @@ class OtherAvatar : public Avatar { public: explicit OtherAvatar(QThread* thread); + ~OtherAvatar(); + virtual void instantiableAvatar() override { }; void createOrb() override; void updateOrbPosition();