Crash fix for AvatarManager when iterating over _avatarHash

The main problem is that a null shared pointer was inserted into the _avatarHash
via the AvatarManager::getAvatarBySessionID().  When the sessionID is not present
in the _avatarHash, [QHash](http://doc.qt.io/qt-5/qhash.html#operator-5b-5d) will *insert*
an empty smart_ptr into the hash.
This commit is contained in:
Anthony J. Thibault 2015-10-30 16:13:04 -07:00
parent 710b51fe14
commit 085282db4f

View file

@ -366,5 +366,10 @@ AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID)
return std::static_pointer_cast<Avatar>(_myAvatar);
}
QReadLocker locker(&_hashLock);
return _avatarHash[sessionID];
auto iter = _avatarHash.find(sessionID);
if (iter != _avatarHash.end()) {
return iter.value();
} else {
return AvatarSharedPointer();
}
}