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()
|
public List<AvatarAttachment> GetAttachments()
|
||||||
{
|
{
|
||||||
List<AvatarAttachment> alist = new List<AvatarAttachment>();
|
List<AvatarAttachment> alist = new List<AvatarAttachment>();
|
||||||
|
|
||||||
|
lock (m_attachments)
|
||||||
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
foreach (AvatarAttachment attach in kvp.Value)
|
foreach (AvatarAttachment attach in kvp.Value)
|
||||||
alist.Add(new AvatarAttachment(attach));
|
alist.Add(new AvatarAttachment(attach));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
|
@ -406,11 +410,14 @@ namespace OpenSim.Framework
|
||||||
// "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
|
// "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
|
||||||
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
||||||
|
|
||||||
|
lock (m_attachments)
|
||||||
|
{
|
||||||
if (!m_attachments.ContainsKey(attach.AttachPoint))
|
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)
|
||||||
{
|
{
|
||||||
|
@ -418,9 +425,12 @@ namespace OpenSim.Framework
|
||||||
// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
|
// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
|
||||||
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
// attach.ItemID, attach.AssetID, attach.AttachPoint);
|
||||||
|
|
||||||
|
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>
|
||||||
/// Set an attachment
|
/// Set an attachment
|
||||||
|
@ -447,12 +457,15 @@ namespace OpenSim.Framework
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
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 true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -493,6 +506,8 @@ namespace OpenSim.Framework
|
||||||
/// <param name="itemID"></param>
|
/// <param name="itemID"></param>
|
||||||
/// <returns>Returns null if this item is not attached.</returns>
|
/// <returns>Returns null if this item is not attached.</returns>
|
||||||
public AvatarAttachment GetAttachmentForItem(UUID itemID)
|
public AvatarAttachment GetAttachmentForItem(UUID itemID)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
|
@ -500,11 +515,14 @@ namespace OpenSim.Framework
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return kvp.Value[index];
|
return kvp.Value[index];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -512,11 +530,14 @@ namespace OpenSim.Framework
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return kvp.Key;
|
return kvp.Key;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DetachAttachment(UUID itemID)
|
public bool DetachAttachment(UUID itemID)
|
||||||
|
{
|
||||||
|
lock (m_attachments)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
|
@ -533,11 +554,14 @@ namespace OpenSim.Framework
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAttachments()
|
public void ClearAttachments()
|
||||||
{
|
{
|
||||||
|
lock (m_attachments)
|
||||||
m_attachments.Clear();
|
m_attachments.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +600,8 @@ namespace OpenSim.Framework
|
||||||
data["visualparams"] = visualparams;
|
data["visualparams"] = visualparams;
|
||||||
|
|
||||||
// Attachments
|
// Attachments
|
||||||
OSDArray attachs = new OSDArray(m_attachments.Count);
|
List<AvatarAttachment> attachments = GetAttachments();
|
||||||
|
OSDArray attachs = new OSDArray(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;
|
||||||
|
|
Loading…
Reference in New Issue