mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Return WeakPointer in avatarHashMap
This commit is contained in:
parent
cb8e4f33bc
commit
9095eeeeb9
2 changed files with 7 additions and 9 deletions
|
@ -51,26 +51,26 @@ void AvatarHashMap::processAvatarMixerDatagram(const QByteArray& datagram, const
|
|||
}
|
||||
|
||||
bool AvatarHashMap::containsAvatarWithDisplayName(const QString& displayName) {
|
||||
return avatarWithDisplayName(displayName) == NULL ? false : true;
|
||||
return !avatarWithDisplayName(displayName).isNull();
|
||||
}
|
||||
|
||||
AvatarData* AvatarHashMap::avatarWithDisplayName(const QString& displayName) {
|
||||
AvatarWeakPointer AvatarHashMap::avatarWithDisplayName(const QString& displayName) {
|
||||
foreach(const AvatarSharedPointer& sharedAvatar, _avatarHash) {
|
||||
if (sharedAvatar->getDisplayName() == displayName) {
|
||||
// this is a match
|
||||
// check if this avatar should still be around
|
||||
if (!shouldKillAvatar(sharedAvatar)) {
|
||||
// we have a match, return the AvatarData
|
||||
return sharedAvatar.data();
|
||||
return sharedAvatar;
|
||||
} else {
|
||||
// we should remove this avatar, but we might not be on a thread that is allowed
|
||||
// so we just return NULL to the caller
|
||||
return NULL;
|
||||
return AvatarWeakPointer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return AvatarWeakPointer();
|
||||
}
|
||||
|
||||
AvatarSharedPointer AvatarHashMap::newSharedAvatar() {
|
||||
|
|
|
@ -30,20 +30,18 @@ class AvatarHashMap : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
AvatarHashMap();
|
||||
|
||||
const AvatarHash& getAvatarHash() { return _avatarHash; }
|
||||
int size() const { return _avatarHash.size(); }
|
||||
|
||||
public slots:
|
||||
void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer<Node>& mixerWeakPointer);
|
||||
bool containsAvatarWithDisplayName(const QString& displayName);
|
||||
AvatarData* avatarWithDisplayName(const QString& displayname);
|
||||
AvatarWeakPointer avatarWithDisplayName(const QString& displayname);
|
||||
|
||||
private slots:
|
||||
void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID);
|
||||
|
||||
protected:
|
||||
AvatarHashMap();
|
||||
virtual AvatarHash::iterator erase(const AvatarHash::iterator& iterator);
|
||||
|
||||
bool shouldKillAvatar(const AvatarSharedPointer& sharedAvatar);
|
||||
|
|
Loading…
Reference in a new issue