mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Merge pull request #5186 from AndrewMeadows/antimony
fix crash when other avatar disconnects unexpectedly
This commit is contained in:
commit
300a879ff4
3 changed files with 9 additions and 6 deletions
|
@ -107,6 +107,7 @@ Avatar::Avatar() :
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::~Avatar() {
|
Avatar::~Avatar() {
|
||||||
|
assert(_motionState == nullptr);
|
||||||
for(auto attachment : _unusedAttachments) {
|
for(auto attachment : _unusedAttachments) {
|
||||||
delete attachment;
|
delete attachment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
// DO NOT update or fade out uninitialized Avatars
|
// DO NOT update or fade out uninitialized Avatars
|
||||||
++avatarIterator;
|
++avatarIterator;
|
||||||
} else if (avatar->shouldDie()) {
|
} else if (avatar->shouldDie()) {
|
||||||
|
removeAvatarMotionState(avatar);
|
||||||
_avatarFades.push_back(avatarIterator.value());
|
_avatarFades.push_back(avatarIterator.value());
|
||||||
avatarIterator = _avatarHash.erase(avatarIterator);
|
avatarIterator = _avatarHash.erase(avatarIterator);
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,12 +164,13 @@ AvatarSharedPointer AvatarManager::addAvatar(const QUuid& sessionUUID, const QWe
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected
|
// protected
|
||||||
void AvatarManager::removeAvatarMotionState(Avatar* avatar) {
|
void AvatarManager::removeAvatarMotionState(AvatarSharedPointer avatar) {
|
||||||
AvatarMotionState* motionState= avatar->_motionState;
|
auto rawPointer = std::static_pointer_cast<Avatar>(avatar);
|
||||||
|
AvatarMotionState* motionState= rawPointer->_motionState;
|
||||||
if (motionState) {
|
if (motionState) {
|
||||||
// clean up physics stuff
|
// clean up physics stuff
|
||||||
motionState->clearObjectBackPointer();
|
motionState->clearObjectBackPointer();
|
||||||
avatar->_motionState = nullptr;
|
rawPointer->_motionState = nullptr;
|
||||||
_avatarMotionStates.remove(motionState);
|
_avatarMotionStates.remove(motionState);
|
||||||
_motionStatesToAdd.remove(motionState);
|
_motionStatesToAdd.remove(motionState);
|
||||||
_motionStatesToDelete.push_back(motionState);
|
_motionStatesToDelete.push_back(motionState);
|
||||||
|
@ -181,7 +183,7 @@ void AvatarManager::removeAvatar(const QUuid& sessionUUID) {
|
||||||
if (avatarIterator != _avatarHash.end()) {
|
if (avatarIterator != _avatarHash.end()) {
|
||||||
std::shared_ptr<Avatar> avatar = std::dynamic_pointer_cast<Avatar>(avatarIterator.value());
|
std::shared_ptr<Avatar> avatar = std::dynamic_pointer_cast<Avatar>(avatarIterator.value());
|
||||||
if (avatar != _myAvatar && avatar->isInitialized()) {
|
if (avatar != _myAvatar && avatar->isInitialized()) {
|
||||||
removeAvatarMotionState(avatar.get());
|
removeAvatarMotionState(avatar);
|
||||||
_avatarFades.push_back(avatarIterator.value());
|
_avatarFades.push_back(avatarIterator.value());
|
||||||
_avatarHash.erase(avatarIterator);
|
_avatarHash.erase(avatarIterator);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +199,7 @@ void AvatarManager::clearOtherAvatars() {
|
||||||
// don't remove myAvatar or uninitialized avatars from the list
|
// don't remove myAvatar or uninitialized avatars from the list
|
||||||
++avatarIterator;
|
++avatarIterator;
|
||||||
} else {
|
} else {
|
||||||
removeAvatarMotionState(avatar.get());
|
removeAvatarMotionState(avatar);
|
||||||
_avatarFades.push_back(avatarIterator.value());
|
_avatarFades.push_back(avatarIterator.value());
|
||||||
avatarIterator = _avatarHash.erase(avatarIterator);
|
avatarIterator = _avatarHash.erase(avatarIterator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ private:
|
||||||
// virtual overrides
|
// virtual overrides
|
||||||
virtual AvatarSharedPointer newSharedAvatar();
|
virtual AvatarSharedPointer newSharedAvatar();
|
||||||
virtual AvatarSharedPointer addAvatar(const QUuid& sessionUUID, const QWeakPointer<Node>& mixerWeakPointer);
|
virtual AvatarSharedPointer addAvatar(const QUuid& sessionUUID, const QWeakPointer<Node>& mixerWeakPointer);
|
||||||
void removeAvatarMotionState(Avatar* avatar);
|
void removeAvatarMotionState(AvatarSharedPointer avatar);
|
||||||
virtual void removeAvatar(const QUuid& sessionUUID);
|
virtual void removeAvatar(const QUuid& sessionUUID);
|
||||||
|
|
||||||
QVector<AvatarSharedPointer> _avatarFades;
|
QVector<AvatarSharedPointer> _avatarFades;
|
||||||
|
|
Loading…
Reference in a new issue