diff options
author | Melanie | 2010-06-29 21:50:52 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-20 21:47:28 +0100 |
commit | 1d6735f0ece1adda715d35ed8e62e9adbddbe4d2 (patch) | |
tree | 148746ba707b217f286b11c7c15a4e00c7601dfd /OpenSim | |
parent | Allow Megaregions to start properly after an unclean shutdown (diff) | |
download | opensim-SC_OLD-1d6735f0ece1adda715d35ed8e62e9adbddbe4d2.zip opensim-SC_OLD-1d6735f0ece1adda715d35ed8e62e9adbddbe4d2.tar.gz opensim-SC_OLD-1d6735f0ece1adda715d35ed8e62e9adbddbe4d2.tar.bz2 opensim-SC_OLD-1d6735f0ece1adda715d35ed8e62e9adbddbe4d2.tar.xz |
Fix the XML serializationt to provide an empty script state element if
the script hasn't yet saved state, or can't save state because of a loop
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index cc37225..92fb934 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1279,9 +1279,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1279 | string xml = instance.GetXMLState(); | 1279 | string xml = instance.GetXMLState(); |
1280 | 1280 | ||
1281 | XmlDocument sdoc = new XmlDocument(); | 1281 | XmlDocument sdoc = new XmlDocument(); |
1282 | sdoc.LoadXml(xml); | 1282 | bool loadedState = true; |
1283 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); | 1283 | try |
1284 | XmlNode rootNode = rootL[0]; | 1284 | { |
1285 | sdoc.LoadXml(xml); | ||
1286 | } | ||
1287 | catch (System.Xml.XmlException e) | ||
1288 | { | ||
1289 | loadedState = false; | ||
1290 | } | ||
1291 | |||
1292 | XmlNodeList rootL = null; | ||
1293 | XmlNode rootNode = null; | ||
1294 | if (loadedState) | ||
1295 | { | ||
1296 | rootL = sdoc.GetElementsByTagName("ScriptState"); | ||
1297 | rootNode = rootL[0]; | ||
1298 | } | ||
1285 | 1299 | ||
1286 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | 1300 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> |
1287 | XmlDocument doc = new XmlDocument(); | 1301 | XmlDocument doc = new XmlDocument(); |
@@ -1297,8 +1311,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1297 | stateData.Attributes.Append(engineName); | 1311 | stateData.Attributes.Append(engineName); |
1298 | doc.AppendChild(stateData); | 1312 | doc.AppendChild(stateData); |
1299 | 1313 | ||
1314 | XmlNode xmlstate = null; | ||
1315 | |||
1300 | // Add <ScriptState>...</ScriptState> | 1316 | // Add <ScriptState>...</ScriptState> |
1301 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | 1317 | if (loadedState) |
1318 | { | ||
1319 | xmlstate = doc.ImportNode(rootNode, true); | ||
1320 | } | ||
1321 | else | ||
1322 | { | ||
1323 | xmlstate = doc.CreateElement("", "ScriptState", ""); | ||
1324 | } | ||
1325 | |||
1302 | stateData.AppendChild(xmlstate); | 1326 | stateData.AppendChild(xmlstate); |
1303 | 1327 | ||
1304 | string assemName = instance.GetAssemblyName(); | 1328 | string assemName = instance.GetAssemblyName(); |