lock AvatarAppearance.m_attachments when we use it
This is partly to address http://opensimulator.org/mantis/view.php?id=5644, though something more thorough is needed.remove-scene-viewer
parent
44a491f36b
commit
dab6387bba
|
@ -391,11 +391,15 @@ namespace OpenSim.Framework
|
|||
public List<AvatarAttachment> GetAttachments()
|
||||
{
|
||||
List<AvatarAttachment> alist = new List<AvatarAttachment>();
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||
{
|
||||
foreach (AvatarAttachment attach in kvp.Value)
|
||||
alist.Add(new AvatarAttachment(attach));
|
||||
}
|
||||
}
|
||||
|
||||
return alist;
|
||||
}
|
||||
|
@ -406,11 +410,14 @@ namespace OpenSim.Framework
|
|||
// "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
|
||||
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
if (!m_attachments.ContainsKey(attach.AttachPoint))
|
||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||
|
||||
m_attachments[attach.AttachPoint].Add(attach);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReplaceAttachment(AvatarAttachment attach)
|
||||
{
|
||||
|
@ -418,9 +425,12 @@ namespace OpenSim.Framework
|
|||
// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
|
||||
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||
m_attachments[attach.AttachPoint].Add(attach);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set an attachment
|
||||
|
@ -447,12 +457,15 @@ namespace OpenSim.Framework
|
|||
return false;
|
||||
|
||||
if (item == UUID.Zero)
|
||||
{
|
||||
lock (m_attachments)
|
||||
{
|
||||
if (m_attachments.ContainsKey(attachpoint))
|
||||
{
|
||||
m_attachments.Remove(attachpoint);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -493,6 +506,8 @@ namespace OpenSim.Framework
|
|||
/// <param name="itemID"></param>
|
||||
/// <returns>Returns null if this item is not attached.</returns>
|
||||
public AvatarAttachment GetAttachmentForItem(UUID itemID)
|
||||
{
|
||||
lock (m_attachments)
|
||||
{
|
||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||
{
|
||||
|
@ -500,11 +515,14 @@ namespace OpenSim.Framework
|
|||
if (index >= 0)
|
||||
return kvp.Value[index];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetAttachpoint(UUID itemID)
|
||||
{
|
||||
lock (m_attachments)
|
||||
{
|
||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||
{
|
||||
|
@ -512,11 +530,14 @@ namespace OpenSim.Framework
|
|||
if (index >= 0)
|
||||
return kvp.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool DetachAttachment(UUID itemID)
|
||||
{
|
||||
lock (m_attachments)
|
||||
{
|
||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||
{
|
||||
|
@ -533,11 +554,14 @@ namespace OpenSim.Framework
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ClearAttachments()
|
||||
{
|
||||
lock (m_attachments)
|
||||
m_attachments.Clear();
|
||||
}
|
||||
|
||||
|
@ -576,7 +600,8 @@ namespace OpenSim.Framework
|
|||
data["visualparams"] = visualparams;
|
||||
|
||||
// Attachments
|
||||
OSDArray attachs = new OSDArray(m_attachments.Count);
|
||||
List<AvatarAttachment> attachments = GetAttachments();
|
||||
OSDArray attachs = new OSDArray(attachments.Count);
|
||||
foreach (AvatarAttachment attach in GetAttachments())
|
||||
attachs.Add(attach.Pack());
|
||||
data["attachments"] = attachs;
|
||||
|
|
Loading…
Reference in New Issue