Make SP.Attachments available as sp.GetAttachments() instead.

The approach here, as in other parts of OpenSim, is to return a copy of the list rather than the attachments list itself
This prevents callers from forgetting to lock the list when they read it, as was happening in various parts of the codebase.
It also improves liveness.
This might improve attachment anomolies when performing region crossings.
This commit is contained in:
Justin Clark-Casey (justincc)
2011-08-31 16:29:51 +01:00
parent 2acfff9f6d
commit 32444d98cb
7 changed files with 101 additions and 75 deletions

View File

@@ -144,14 +144,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
// FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it
List<SceneObjectGroup> attachments = sp.Attachments;
lock (attachments)
{
foreach (SceneObjectGroup att in attachments)
scene.DeleteSceneObject(att, false);
foreach (SceneObjectGroup att in sp.GetAttachments())
scene.DeleteSceneObject(att, false);
attachments.Clear();
}
sp.ClearAttachments();
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
sp.Appearance = npcAppearance;