make sog, sop and sop inventory IDisposable

master
UbitUmarov 2020-05-14 12:02:46 +01:00
parent dd55a3d19c
commit 8b77162020
5 changed files with 104 additions and 19 deletions

View File

@ -876,7 +876,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.DeleteSceneObject(so, false, false);
so.RemoveScriptInstances(true);
so.Clear();
so.Dispose();
return;
}
@ -1213,7 +1213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Now, remove the scripts
so.RemoveScriptInstances(true);
so.Clear();
so.Dispose();
}
protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(

View File

@ -2795,7 +2795,7 @@ namespace OpenSim.Region.Framework.Scenes
// use this to mean also full delete
if (removeScripts)
group.Clear();
group.Dispose();
partList = null;
// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
}

View File

@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.Scenes
/// A scene object group is conceptually an object in the scene. The object is constituted of SceneObjectParts
/// (often known as prims), one of which is considered the root part.
/// </summary>
public partial class SceneObjectGroup : EntityBase, ISceneObject
public partial class SceneObjectGroup : EntityBase, ISceneObject, IDisposable
{
// Axis selection bitmask used by SetAxisRotation()
// Just happen to be the same bits used by llSetStatus() and defined in ScriptBaseClass.
@ -907,7 +907,7 @@ namespace OpenSim.Region.Framework.Scenes
avsToCrossFar.Clear();
avsToCross.Clear();
sog.RemoveScriptInstances(true);
sog.Clear();
sog.Dispose();
return sog;
}
else
@ -1362,6 +1362,42 @@ namespace OpenSim.Region.Framework.Scenes
{
}
~SceneObjectGroup()
{
Dispose(false);
}
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!disposed)
{
IsDeleted = true;
SceneObjectPart[] parts = m_parts.GetArray();
for(int i= 0; i < parts.Length; ++i)
parts[i].Dispose();
m_parts.Clear();
m_sittingAvatars.Clear();
// m_rootPart = null;
m_targets.Clear();
m_partsNameToLinkMap.Clear();
disposed = true;
}
}
public void LoadScriptState(XmlDocument doc)
{
XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState");
@ -2412,7 +2448,7 @@ namespace OpenSim.Region.Framework.Scenes
}
});
backup_group.Clear();
backup_group.Dispose();
backup_group = null;
}
}
@ -5277,17 +5313,6 @@ namespace OpenSim.Region.Framework.Scenes
InvalidateEffectivePerms();
}
// clear some references to easy cg
public void Clear()
{
m_parts.Clear();
m_sittingAvatars.Clear();
// m_rootPart = null;
m_targets.Clear();
m_partsNameToLinkMap.Clear();
}
private Dictionary<string,int> m_partsNameToLinkMap = new Dictionary<string, int>();
private string GetLinkNumber_lastname;
private int GetLinkNumber_lastnumber;

View File

@ -93,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
#endregion Enumerations
public class SceneObjectPart : ISceneEntity
public class SceneObjectPart : ISceneEntity, IDisposable
{
/// <value>
/// Denote all sides of the prim
@ -454,6 +454,40 @@ namespace OpenSim.Region.Framework.Scenes
AggregateInnerPerms();
}
~SceneObjectPart()
{
Dispose(false);
}
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!disposed)
{
if (KeyframeMotion != null)
{
KeyframeMotion.Delete();
KeyframeMotion = null;
}
if (PhysActor != null)
RemoveFromPhysics();
if (m_inventory != null)
{
m_inventory.Dispose();
m_inventory = null;
}
disposed = true;
}
}
#endregion Constructors
#region XML Schema

View File

@ -43,7 +43,7 @@ using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Region.Framework.Scenes
{
public class SceneObjectPartInventory : IEntityInventory
public class SceneObjectPartInventory : IEntityInventory , IDisposable
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -125,6 +125,32 @@ namespace OpenSim.Region.Framework.Scenes
m_part = part;
}
~SceneObjectPartInventory()
{
Dispose(false);
}
private bool disposed = false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if (!disposed)
{
if (m_items != null)
{
m_items.Dispose();
m_items = null;
}
disposed = true;
}
}
/// <summary>
/// Force the task inventory of this prim to persist at the next update sweep
/// </summary>