mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-28 23:27:09 +02:00
make sure to lock data
This commit is contained in:
parent
282b364fad
commit
21d760a533
3 changed files with 9 additions and 1 deletions
|
@ -2366,6 +2366,12 @@ AvatarEntityMap AvatarData::getAvatarEntityData() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AvatarData::insertDetachedEntityID(const QUuid entityID) {
|
||||||
|
_avatarEntitiesLock.withWriteLock([&] {
|
||||||
|
_avatarEntityDetached.insert(entityID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void AvatarData::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
|
void AvatarData::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
|
||||||
if (avatarEntityData.size() > MAX_NUM_AVATAR_ENTITIES) {
|
if (avatarEntityData.size() > MAX_NUM_AVATAR_ENTITIES) {
|
||||||
// the data is suspect
|
// the data is suspect
|
||||||
|
|
|
@ -615,7 +615,7 @@ public:
|
||||||
Q_INVOKABLE AvatarEntityMap getAvatarEntityData() const;
|
Q_INVOKABLE AvatarEntityMap getAvatarEntityData() const;
|
||||||
Q_INVOKABLE void setAvatarEntityData(const AvatarEntityMap& avatarEntityData);
|
Q_INVOKABLE void setAvatarEntityData(const AvatarEntityMap& avatarEntityData);
|
||||||
void setAvatarEntityDataChanged(bool value) { _avatarEntityDataChanged = value; }
|
void setAvatarEntityDataChanged(bool value) { _avatarEntityDataChanged = value; }
|
||||||
void insertDetachedEntityID(const QUuid entityID) { _avatarEntityDetached.insert(entityID); }
|
void insertDetachedEntityID(const QUuid entityID);
|
||||||
AvatarEntityIDs getAndClearRecentlyDetachedIDs();
|
AvatarEntityIDs getAndClearRecentlyDetachedIDs();
|
||||||
|
|
||||||
// thread safe
|
// thread safe
|
||||||
|
|
|
@ -502,6 +502,8 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
||||||
AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID);
|
AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID);
|
||||||
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
|
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
|
||||||
// don't delete other avatar's avatarEntities
|
// don't delete other avatar's avatarEntities
|
||||||
|
// If you actually own the entity but the onwership is not set because of a domain switch
|
||||||
|
// the line below make sure the entity is deleted.
|
||||||
myAvatar->insertDetachedEntityID(id);
|
myAvatar->insertDetachedEntityID(id);
|
||||||
shouldDelete = false;
|
shouldDelete = false;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue