mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
Actually remove the script if it tries to remove itself.
Fixes Mantis #2929
This commit is contained in:
@@ -3577,7 +3577,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
if (item.Name == name)
|
||||
{
|
||||
m_host.Inventory.RemoveInventoryItem(item.ItemID);
|
||||
if (item.ItemID == m_itemID)
|
||||
throw new ScriptDeleteException();
|
||||
else
|
||||
m_host.Inventory.RemoveInventoryItem(item.ItemID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ScriptDeleteException : Exception
|
||||
{
|
||||
public ScriptDeleteException()
|
||||
{
|
||||
}
|
||||
|
||||
protected ScriptDeleteException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class DetectParams
|
||||
{
|
||||
public DetectParams()
|
||||
|
||||
@@ -707,11 +707,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[Script] Exception: {0}", e.Message);
|
||||
// m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
|
||||
m_InEvent = false;
|
||||
m_CurrentEvent = String.Empty;
|
||||
|
||||
if ((!(e is TargetInvocationException) || !(e.InnerException is SelfDeleteException)) && (!(e is ThreadAbortException)))
|
||||
if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -727,10 +727,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
}
|
||||
catch (Exception e2) // LEGIT: User Scripting
|
||||
{
|
||||
m_log.Error("[Script]: "+
|
||||
m_log.Error("[SCRIPT]: "+
|
||||
"Error displaying error in-world: " +
|
||||
e2.ToString());
|
||||
m_log.Error("[Script]: " +
|
||||
m_log.Error("[SCRIPT]: " +
|
||||
"Errormessage: Error compiling script:\r\n" +
|
||||
e.ToString());
|
||||
}
|
||||
@@ -741,6 +741,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
if (part != null && part.ParentGroup != null)
|
||||
m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
|
||||
}
|
||||
else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
|
||||
{
|
||||
m_InSelfDelete = true;
|
||||
if (part != null && part.ParentGroup != null)
|
||||
part.Inventory.RemoveInventoryItem(m_ItemID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user