Lock the attachments dict so it doesn't get out of sync when iterating
parent
4b979362e9
commit
b1a5c03985
|
@ -413,6 +413,8 @@ namespace OpenSim.Framework
|
||||||
/// duplicate attachpoints
|
/// duplicate attachpoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AvatarAttachment> GetAttachments()
|
public List<AvatarAttachment> GetAttachments()
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
List<AvatarAttachment> alist = new List<AvatarAttachment>();
|
List<AvatarAttachment> alist = new List<AvatarAttachment>();
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
|
@ -423,19 +425,26 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void AppendAttachment(AvatarAttachment attach)
|
internal void AppendAttachment(AvatarAttachment attach)
|
||||||
{
|
{
|
||||||
if (! m_attachments.ContainsKey(attach.AttachPoint))
|
lock (m_attachments)
|
||||||
|
{
|
||||||
|
if (!m_attachments.ContainsKey(attach.AttachPoint))
|
||||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||||
m_attachments[attach.AttachPoint].Add(attach);
|
m_attachments[attach.AttachPoint].Add(attach);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void ReplaceAttachment(AvatarAttachment attach)
|
internal void ReplaceAttachment(AvatarAttachment attach)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
|
||||||
m_attachments[attach.AttachPoint].Add(attach);
|
m_attachments[attach.AttachPoint].Add(attach);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an attachment, if the attachpoint has the
|
/// Add an attachment, if the attachpoint has the
|
||||||
|
@ -449,11 +458,14 @@ namespace OpenSim.Framework
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (item == UUID.Zero)
|
if (item == UUID.Zero)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
if (m_attachments.ContainsKey(attachpoint))
|
if (m_attachments.ContainsKey(attachpoint))
|
||||||
m_attachments.Remove(attachpoint);
|
m_attachments.Remove(attachpoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if this is an append or a replace, 0x80 marks it as an append
|
// check if this is an append or a replace, 0x80 marks it as an append
|
||||||
if ((attachpoint & 0x80) > 0)
|
if ((attachpoint & 0x80) > 0)
|
||||||
|
@ -469,6 +481,8 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetAttachpoint(UUID itemID)
|
public int GetAttachpoint(UUID itemID)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
|
@ -479,8 +493,11 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void DetachAttachment(UUID itemID)
|
public void DetachAttachment(UUID itemID)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
|
@ -497,11 +514,15 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearAttachments()
|
public void ClearAttachments()
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
m_attachments.Clear();
|
m_attachments.Clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Packing Functions
|
#region Packing Functions
|
||||||
|
|
||||||
|
@ -537,11 +558,14 @@ namespace OpenSim.Framework
|
||||||
OSDBinary visualparams = new OSDBinary(m_visualparams);
|
OSDBinary visualparams = new OSDBinary(m_visualparams);
|
||||||
data["visualparams"] = visualparams;
|
data["visualparams"] = visualparams;
|
||||||
|
|
||||||
|
lock (m_attachments)
|
||||||
|
{
|
||||||
// Attachments
|
// Attachments
|
||||||
OSDArray attachs = new OSDArray(m_attachments.Count);
|
OSDArray attachs = new OSDArray(m_attachments.Count);
|
||||||
foreach (AvatarAttachment attach in GetAttachments())
|
foreach (AvatarAttachment attach in GetAttachments())
|
||||||
attachs.Add(attach.Pack());
|
attachs.Add(attach.Pack());
|
||||||
data["attachments"] = attachs;
|
data["attachments"] = attachs;
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue