remove orb in the otherAvatar destructor, and check

_otherAvatarOrbMeshPlaceholder pointer before updating the position
This commit is contained in:
amantley 2018-06-27 11:15:33 -07:00
parent eba4a27329
commit 1804422df0
2 changed files with 9 additions and 1 deletions

View file

@ -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() {

View file

@ -17,6 +17,8 @@
class OtherAvatar : public Avatar {
public:
explicit OtherAvatar(QThread* thread);
~OtherAvatar();
virtual void instantiableAvatar() override { };
void createOrb() override;
void updateOrbPosition();