diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index c0edaba5bf..5acad88e43 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -122,7 +122,10 @@ namespace OpenSim.Region.Environment.Scenes } //SceneObjects.Clear(); - Entities.Clear(); + lock (Entities) + { + Entities.Clear(); + } } #region Update Methods @@ -756,7 +759,8 @@ namespace OpenSim.Region.Environment.Scenes // Primitive Ray Tracing float closestDistance = 280f; EntityIntersection returnResult = new EntityIntersection(); - foreach (EntityBase ent in Entities.Values) + List EntityList = GetEntities(); + foreach (EntityBase ent in EntityList) { if (ent is SceneObjectGroup) { @@ -845,7 +849,11 @@ namespace OpenSim.Region.Environment.Scenes /// protected internal List GetEntities() { - return new List(Entities.Values); + lock(Entities) + { + if (0 == Entities.Count) return null; + return new List(Entities.Values); + } } protected internal Dictionary GetTopScripts()