diff options
author | Justin Clark-Casey (justincc) | 2012-10-25 22:55:29 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-25 22:55:29 +0100 |
commit | 22e216fd123744f6c87024fc18f3c9b306777fe2 (patch) | |
tree | 5531c337a371e292a65ab2830cd7b5230165ffdc /OpenSim/Region/Framework/Scenes | |
parent | Fix script error messages not showing up in viewer 3 and associated viewers. (diff) | |
download | opensim-SC-22e216fd123744f6c87024fc18f3c9b306777fe2.zip opensim-SC-22e216fd123744f6c87024fc18f3c9b306777fe2.tar.gz opensim-SC-22e216fd123744f6c87024fc18f3c9b306777fe2.tar.bz2 opensim-SC-22e216fd123744f6c87024fc18f3c9b306777fe2.tar.xz |
In Scene.Close(), dispose of the physics scene after base.Close() since script events can still access Physics scene until the script engine shuts down (triggered off base.Close())
XEngine listeners to EventManager.OnShutdown which is triggered from base.Close().
Possibly it could listen for the earlier OnSceneShuttingDown instead, but the easier solution right now is to relocate disposal of the physics scene.
This bug has existed since c150320 (Thu Jul 26 15:27:18 2012) and was in 0.7.4
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 17 |
2 files changed, 25 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 532598a..d48dc11 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1310,6 +1310,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1310 | 1310 | ||
1311 | m_sceneGraph.Close(); | 1311 | m_sceneGraph.Close(); |
1312 | 1312 | ||
1313 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | ||
1314 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | ||
1315 | |||
1316 | base.Close(); | ||
1317 | |||
1318 | // XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence. | ||
1319 | // Therefore. we must dispose of the PhysicsScene after this to prevent a window where script code can | ||
1320 | // attempt to reference a null or disposed physics scene. | ||
1313 | if (PhysicsScene != null) | 1321 | if (PhysicsScene != null) |
1314 | { | 1322 | { |
1315 | PhysicsScene phys = PhysicsScene; | 1323 | PhysicsScene phys = PhysicsScene; |
@@ -1318,12 +1326,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1318 | phys.Dispose(); | 1326 | phys.Dispose(); |
1319 | phys = null; | 1327 | phys = null; |
1320 | } | 1328 | } |
1321 | |||
1322 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | ||
1323 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | ||
1324 | |||
1325 | // call the base class Close method. | ||
1326 | base.Close(); | ||
1327 | } | 1329 | } |
1328 | 1330 | ||
1329 | /// <summary> | 1331 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index d722a09..ac3da1e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -65,5 +65,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
65 | 65 | ||
66 | Assert.That(scene.Frame, Is.EqualTo(1)); | 66 | Assert.That(scene.Frame, Is.EqualTo(1)); |
67 | } | 67 | } |
68 | |||
69 | [Test] | ||
70 | public void TestShutdownScene() | ||
71 | { | ||
72 | TestHelpers.InMethod(); | ||
73 | |||
74 | Scene scene = new SceneHelpers().SetupScene(); | ||
75 | scene.Close(); | ||
76 | |||
77 | Assert.That(scene.ShuttingDown, Is.True); | ||
78 | Assert.That(scene.Active, Is.False); | ||
79 | |||
80 | // Trying to update a shutdown scene should result in no update | ||
81 | scene.Update(1); | ||
82 | |||
83 | Assert.That(scene.Frame, Is.EqualTo(0)); | ||
84 | } | ||
68 | } | 85 | } |
69 | } \ No newline at end of file | 86 | } \ No newline at end of file |