lock attachments when enumerating through them in ScenePresence.CopyTo().

May have some effect on http://opensimulator.org/mantis/view.php?id=5644
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-09-10 01:09:17 +01:00
parent 9c32b131fd
commit 728fd0b1b8
2 changed files with 22 additions and 19 deletions

View File

@ -441,7 +441,6 @@ namespace OpenSim.Framework
args["controllers"] = controls; args["controllers"] = controls;
} }
if ((CallbackURI != null) && (!CallbackURI.Equals(""))) if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI); args["callback_uri"] = OSD.FromString(CallbackURI);

View File

@ -3141,26 +3141,30 @@ namespace OpenSim.Region.Framework.Scenes
catch { } catch { }
// Attachment objects // Attachment objects
if (m_attachments != null && m_attachments.Count > 0) lock (m_attachments)
{ {
cAgent.AttachmentObjects = new List<ISceneObject>(); if (m_attachments.Count > 0)
cAgent.AttachmentObjectStates = new List<string>();
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
m_InTransitScriptStates.Clear();
foreach (SceneObjectGroup sog in m_attachments)
{ {
// We need to make a copy and pass that copy cAgent.AttachmentObjects = new List<ISceneObject>();
// because of transfers withn the same sim cAgent.AttachmentObjectStates = new List<string>();
ISceneObject clone = sog.CloneForNewScene(); // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
// Attachment module assumes that GroupPosition holds the offsets...! m_InTransitScriptStates.Clear();
((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
((SceneObjectGroup)clone).IsAttachment = false; foreach (SceneObjectGroup sog in m_attachments)
cAgent.AttachmentObjects.Add(clone); {
string state = sog.GetStateSnapshot(); // We need to make a copy and pass that copy
cAgent.AttachmentObjectStates.Add(state); // because of transfers withn the same sim
m_InTransitScriptStates.Add(state); ISceneObject clone = sog.CloneForNewScene();
// Let's remove the scripts of the original object here // Attachment module assumes that GroupPosition holds the offsets...!
sog.RemoveScriptInstances(true); ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
((SceneObjectGroup)clone).IsAttachment = false;
cAgent.AttachmentObjects.Add(clone);
string state = sog.GetStateSnapshot();
cAgent.AttachmentObjectStates.Add(state);
m_InTransitScriptStates.Add(state);
// Let's remove the scripts of the original object here
sog.RemoveScriptInstances(true);
}
} }
} }
} }