diff options
author | Melanie | 2010-06-29 21:50:52 +0100 |
---|---|---|
committer | Melanie | 2010-06-29 21:50:52 +0100 |
commit | 6701fc2ffa426912fe7a4b208eaeec6d2defce15 (patch) | |
tree | c50ac740fc4850dd5c7fc0e4eb571814a2c11561 /OpenSim/Region/ScriptEngine/XEngine | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC_OLD-6701fc2ffa426912fe7a4b208eaeec6d2defce15.zip opensim-SC_OLD-6701fc2ffa426912fe7a4b208eaeec6d2defce15.tar.gz opensim-SC_OLD-6701fc2ffa426912fe7a4b208eaeec6d2defce15.tar.bz2 opensim-SC_OLD-6701fc2ffa426912fe7a4b208eaeec6d2defce15.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/Region/ScriptEngine/XEngine')
-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 61a2088..4715690 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1274,9 +1274,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1274 | string xml = instance.GetXMLState(); | 1274 | string xml = instance.GetXMLState(); |
1275 | 1275 | ||
1276 | XmlDocument sdoc = new XmlDocument(); | 1276 | XmlDocument sdoc = new XmlDocument(); |
1277 | sdoc.LoadXml(xml); | 1277 | bool loadedState = true; |
1278 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); | 1278 | try |
1279 | XmlNode rootNode = rootL[0]; | 1279 | { |
1280 | sdoc.LoadXml(xml); | ||
1281 | } | ||
1282 | catch (System.Xml.XmlException e) | ||
1283 | { | ||
1284 | loadedState = false; | ||
1285 | } | ||
1286 | |||
1287 | XmlNodeList rootL = null; | ||
1288 | XmlNode rootNode = null; | ||
1289 | if (loadedState) | ||
1290 | { | ||
1291 | rootL = sdoc.GetElementsByTagName("ScriptState"); | ||
1292 | rootNode = rootL[0]; | ||
1293 | } | ||
1280 | 1294 | ||
1281 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | 1295 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> |
1282 | XmlDocument doc = new XmlDocument(); | 1296 | XmlDocument doc = new XmlDocument(); |
@@ -1292,8 +1306,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1292 | stateData.Attributes.Append(engineName); | 1306 | stateData.Attributes.Append(engineName); |
1293 | doc.AppendChild(stateData); | 1307 | doc.AppendChild(stateData); |
1294 | 1308 | ||
1309 | XmlNode xmlstate = null; | ||
1310 | |||
1295 | // Add <ScriptState>...</ScriptState> | 1311 | // Add <ScriptState>...</ScriptState> |
1296 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | 1312 | if (loadedState) |
1313 | { | ||
1314 | xmlstate = doc.ImportNode(rootNode, true); | ||
1315 | } | ||
1316 | else | ||
1317 | { | ||
1318 | xmlstate = doc.CreateElement("", "ScriptState", ""); | ||
1319 | } | ||
1320 | |||
1297 | stateData.AppendChild(xmlstate); | 1321 | stateData.AppendChild(xmlstate); |
1298 | 1322 | ||
1299 | string assemName = instance.GetAssemblyName(); | 1323 | string assemName = instance.GetAssemblyName(); |