aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-31 16:29:51 +0100
committerJustin Clark-Casey (justincc)2011-08-31 16:29:51 +0100
commit32444d98cb13423fdf8c874e4fbb7ea17670d7c5 (patch)
tree4c384f277afc6138a050706eaaf839caeed22d1d /OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
parentremove pointless ToArray() call in AttachmentsModule.SaveChangedAttachments() (diff)
downloadopensim-SC_OLD-32444d98cb13423fdf8c874e4fbb7ea17670d7c5.zip
opensim-SC_OLD-32444d98cb13423fdf8c874e4fbb7ea17670d7c5.tar.gz
opensim-SC_OLD-32444d98cb13423fdf8c874e4fbb7ea17670d7c5.tar.bz2
opensim-SC_OLD-32444d98cb13423fdf8c874e4fbb7ea17670d7c5.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs19
1 files changed, 7 insertions, 12 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f4bc495..9e5ce8f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -136,10 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
136 136
137 public void SaveChangedAttachments(IScenePresence sp) 137 public void SaveChangedAttachments(IScenePresence sp)
138 { 138 {
139 // Need to copy this list because DetachToInventoryPrep mods it 139 foreach (SceneObjectGroup grp in sp.GetAttachments())
140 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(sp.Attachments);
141
142 foreach (SceneObjectGroup grp in attachments)
143 { 140 {
144 if (grp.HasGroupChanged) // Resizer scripts? 141 if (grp.HasGroupChanged) // Resizer scripts?
145 { 142 {
@@ -273,14 +270,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
273 270
274 // Remove any previous attachments 271 // Remove any previous attachments
275 UUID itemID = UUID.Zero; 272 UUID itemID = UUID.Zero;
276 foreach (SceneObjectGroup grp in sp.Attachments) 273
277 { 274 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
278 if (grp.AttachmentPoint == attachmentPt) 275
279 { 276 // At the moment we can only deal with a single attachment
280 itemID = grp.GetFromItemID(); 277 if (attachments.Count != 0)
281 break; 278 itemID = attachments[0].GetFromItemID();
282 }
283 }
284 279
285 if (itemID != UUID.Zero) 280 if (itemID != UUID.Zero)
286 DetachSingleAttachmentToInv(itemID, sp); 281 DetachSingleAttachmentToInv(itemID, sp);