From 1876ce90af98722a205d1c7181ef66b6a2b54fc5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 22 Dec 2009 09:24:01 +0000 Subject: FINALLY! Script compile errors now appear in the script error pane, not in a funky debug window. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 163 ++++++++++++++----------- 1 file changed, 93 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 035686e..11b02e1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -77,6 +77,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine private string m_ScriptErrorMessage; private Dictionary m_uniqueScripts = new Dictionary(); private bool m_AppDomainLoading; + private Dictionary m_ScriptErrors = + new Dictionary(); // disable warning: need to keep a reference to XEngine.EventManager // alive to avoid it being garbage collected @@ -589,87 +591,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine Dictionary, KeyValuePair> linemap; - try + lock(m_ScriptErrors) { - lock (m_AddingAssemblies) + try { - m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); - if (!m_AddingAssemblies.ContainsKey(assembly)) { - m_AddingAssemblies[assembly] = 1; - } else { - m_AddingAssemblies[assembly]++; + lock (m_AddingAssemblies) + { + m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); + if (!m_AddingAssemblies.ContainsKey(assembly)) { + m_AddingAssemblies[assembly] = 1; + } else { + m_AddingAssemblies[assembly]++; + } } - } - string[] warnings = m_Compiler.GetWarnings(); + string[] warnings = m_Compiler.GetWarnings(); - if (warnings != null && warnings.Length != 0) - { - foreach (string warning in warnings) + if (warnings != null && warnings.Length != 0) { - try + foreach (string warning in warnings) { - // DISPLAY WARNING INWORLD - string text = "Warning:\n" + warning; - if (text.Length > 1000) - text = text.Substring(0, 1000); - if (!ShowScriptSaveResponse(item.OwnerID, - assetID, text, true)) - { - if (presence != null && (!postOnRez)) - presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); - - World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - } - catch (Exception e2) // LEGIT: User Scripting - { - m_log.Error("[XEngine]: " + - "Error displaying warning in-world: " + - e2.ToString()); - m_log.Error("[XEngine]: " + - "Warning:\r\n" + - warning); + if (!m_ScriptErrors.ContainsKey(itemID)) + m_ScriptErrors[itemID] = new ArrayList(); + + m_ScriptErrors[itemID].Add(warning); + // try + // { + // // DISPLAY WARNING INWORLD + // string text = "Warning:\n" + warning; + // if (text.Length > 1000) + // text = text.Substring(0, 1000); + // if (!ShowScriptSaveResponse(item.OwnerID, + // assetID, text, true)) + // { + // if (presence != null && (!postOnRez)) + // presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); + // + // World.SimChat(Utils.StringToBytes(text), + // ChatTypeEnum.DebugChannel, 2147483647, + // part.AbsolutePosition, + // part.Name, part.UUID, false); + // } + // } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[XEngine]: " + + // "Error displaying warning in-world: " + + // e2.ToString()); + // m_log.Error("[XEngine]: " + + // "Warning:\r\n" + + // warning); + // } } } } - } - catch (Exception e) - { - try + catch (Exception e) { - // DISPLAY ERROR INWORLD - m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); - - m_ScriptFailCount++; - string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); - if (text.Length > 1000) - text = text.Substring(0, 1000); - if (!ShowScriptSaveResponse(item.OwnerID, - assetID, text, false)) - { - if (presence != null && (!postOnRez)) - presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); - World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - } - catch (Exception e2) // LEGIT: User Scripting - { - m_log.Error("[XEngine]: "+ - "Error displaying error in-world: " + - e2.ToString()); - m_log.Error("[XEngine]: " + - "Errormessage: Error compiling script:\r\n" + - e.Message.ToString()); - } + // try + // { + if (!m_ScriptErrors.ContainsKey(itemID)) + m_ScriptErrors[itemID] = new ArrayList(); + // DISPLAY ERROR INWORLD + // m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); + // + m_ScriptFailCount++; + m_ScriptErrors[itemID].Add(e.Message.ToString()); + // string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); + // if (text.Length > 1000) + // text = text.Substring(0, 1000); + // if (!ShowScriptSaveResponse(item.OwnerID, + // assetID, text, false)) + // { + // if (presence != null && (!postOnRez)) + // presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); + // World.SimChat(Utils.StringToBytes(text), + // ChatTypeEnum.DebugChannel, 2147483647, + // part.AbsolutePosition, + // part.Name, part.UUID, false); + // } + // } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[XEngine]: "+ + // "Error displaying error in-world: " + + // e2.ToString()); + // m_log.Error("[XEngine]: " + + // "Errormessage: Error compiling script:\r\n" + + // e.Message.ToString()); + // } - return false; + return false; + } } lock (m_Scripts) @@ -1473,7 +1485,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine public ArrayList GetScriptErrors(UUID itemID) { - return new ArrayList(); + System.Threading.Thread.Sleep(1000); + + lock (m_ScriptErrors) + { + if (m_ScriptErrors.ContainsKey(itemID)) + { + ArrayList ret = m_ScriptErrors[itemID]; + m_ScriptErrors.Remove(itemID); + return ret; + } + return new ArrayList(); + } } } } -- cgit v1.1