From 32444d98cb13423fdf8c874e4fbb7ea17670d7c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 16:29:51 +0100 Subject: 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. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 79c79e4..e58dca2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -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 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; -- cgit v1.1