mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 09:33:49 +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;
|
||||
}
|
||||
|
||||
void AvatarData::insertDetachedEntityID(const QUuid entityID) {
|
||||
_avatarEntitiesLock.withWriteLock([&] {
|
||||
_avatarEntityDetached.insert(entityID);
|
||||
});
|
||||
}
|
||||
|
||||
void AvatarData::setAvatarEntityData(const AvatarEntityMap& avatarEntityData) {
|
||||
if (avatarEntityData.size() > MAX_NUM_AVATAR_ENTITIES) {
|
||||
// the data is suspect
|
||||
|
|
|
@ -615,7 +615,7 @@ public:
|
|||
Q_INVOKABLE AvatarEntityMap getAvatarEntityData() const;
|
||||
Q_INVOKABLE void setAvatarEntityData(const AvatarEntityMap& avatarEntityData);
|
||||
void setAvatarEntityDataChanged(bool value) { _avatarEntityDataChanged = value; }
|
||||
void insertDetachedEntityID(const QUuid entityID) { _avatarEntityDetached.insert(entityID); }
|
||||
void insertDetachedEntityID(const QUuid entityID);
|
||||
AvatarEntityIDs getAndClearRecentlyDetachedIDs();
|
||||
|
||||
// thread safe
|
||||
|
|
|
@ -502,6 +502,8 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
|||
AvatarSharedPointer myAvatar = avatarHashMap->getAvatarBySessionID(myNodeID);
|
||||
if (entity->getClientOnly() && entity->getOwningAvatarID() != myNodeID) {
|
||||
// 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);
|
||||
shouldDelete = false;
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue