From 17bdc45c5ce623549b185a6c4bd5e8fdf00c8d8e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 4 Aug 2009 03:17:13 +0100 Subject: [PATCH] Add plumbing for the SceneObjectDeleter to wait for the script engine to allow final deletion of objects. Meant to support the attach(NULL_KEY) event, --- .../Framework/Interfaces/IEntityInventory.cs | 2 ++ .../Framework/Interfaces/IScriptModule.cs | 1 + .../Scenes/AsyncSceneObjectGroupDeleter.cs | 11 +++++--- .../Framework/Scenes/SceneObjectGroup.cs | 11 ++++++++ .../Framework/Scenes/SceneObjectPart.cs | 5 ++++ .../Scenes/SceneObjectPartInventory.cs | 25 +++++++++++++++++++ .../ScriptEngine/DotNetEngine/ScriptEngine.cs | 5 ++++ .../Interfaces/IScriptInstance.cs | 1 + .../Shared/Instance/ScriptInstance.cs | 5 ++++ .../Region/ScriptEngine/XEngine/XEngine.cs | 9 +++++++ 10 files changed, 72 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index f040365b9b..1ed92fb409 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -197,5 +197,7 @@ namespace OpenSim.Region.Framework.Interfaces /// A /// Dictionary GetScriptStates(); + + bool CanBeDeleted(); } } diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 2c4ddbd948..10835b9db4 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -36,6 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces string GetAssemblyName(UUID itemID); string GetXMLState(UUID itemID); + bool CanBeDeleted(UUID itemID); bool PostScriptEvent(UUID itemID, string name, Object[] args); bool PostObjectEvent(UUID itemID, string name, Object[] args); diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 4ef174984b..f8208eca32 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes while (InventoryDeQueueAndDelete()) { - m_log.Debug("[SCENE]: Sent item successfully to inventory, continuing..."); + //m_log.Debug("[SCENE]: Sent item successfully to inventory, continuing..."); } } @@ -128,11 +128,16 @@ namespace OpenSim.Region.Framework.Scenes int left = m_inventoryDeletes.Count; if (left > 0) { + x = m_inventoryDeletes.Dequeue(); + if (!x.objectGroup.CanBeDeleted()) + { + m_inventoryDeletes.Enqueue(x); + return true; + } + m_log.DebugFormat( "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); - x = m_inventoryDeletes.Dequeue(); - try { m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0f7bd006da..21e133b547 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3383,5 +3383,16 @@ namespace OpenSim.Region.Framework.Scenes SetFromAssetID(uuid); } #endregion + + public bool CanBeDeleted() + { + foreach (SceneObjectPart part in Children.Values) + { + if (!part.CanBeDeleted()) + return false; + } + + return true; + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a4d455c631..bc117090f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3787,5 +3787,10 @@ if (m_shape != null) { Inventory.ApplyNextOwnerPermissions(); } + + public bool CanBeDeleted() + { + return Inventory.CanBeDeleted(); + } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 084aa509d9..582f44d60a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -910,5 +910,30 @@ namespace OpenSim.Region.Framework.Scenes } return ret; } + + public bool CanBeDeleted() + { + if (!ContainsScripts()) + return true; + + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + + if (engines == null) // No engine at all + return true; + + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.InvType == (int)InventoryType.LSL) + { + foreach (IScriptModule e in engines) + { + if(!e.CanBeDeleted(item.ItemID)) + return false; + } + } + } + + return true; + } } } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index ec94afac7b..987827c4d3 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -476,5 +476,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { return ""; } + + public bool CanBeDeleted(UUID itemID) + { + return true; + } } } diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 64f7077e4d..c2fce2fab3 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -95,6 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces UUID GetDetectID(int idx); void SaveState(string assembly); void DestroyScriptInstance(); + bool CanBeDeleted(); IScriptApi GetApi(string name); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 2457b3a909..42d61a7b17 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -991,5 +991,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { get { return m_RegionID; } } + + public bool CanBeDeleted() + { + return true; + } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index dff53dddd3..c7673c7a75 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1241,5 +1241,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine return ""; return instance.GetXMLState(); } + + public bool CanBeDeleted(UUID itemID) + { + IScriptInstance instance = GetInstance(itemID); + if (instance == null) + return true; + + return instance.CanBeDeleted(); + } } }