From cd6f3b147d0d9d412a0fd99f5640f343b59ed53a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 26 Sep 2012 23:31:10 +0100 Subject: [PATCH] Don't store undo states if a scene object is manipulated when it is not in a scene. Adds regression test for this. --- .../Framework/Scenes/SceneObjectPart.cs | 6 ++--- .../Scenes/Tests/SceneObjectUndoRedoTests.cs | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a707f135d6..49f55b1379 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3150,6 +3150,9 @@ namespace OpenSim.Region.Framework.Scenes public void StoreUndoState(bool forGroup) { + if (ParentGroup == null || ParentGroup.Scene == null) + return; + if (Undoing) { // m_log.DebugFormat( @@ -3163,9 +3166,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - if (ParentGroup == null) - return; - lock (m_undo) { if (m_undo.Count > 0) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs index c93562d500..133fac573a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs @@ -102,6 +102,29 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); } + [Test] + public void TestNoUndoOnObjectsNotInScene() + { + TestHelpers.InMethod(); + + Vector3 firstSize = new Vector3(2, 3, 4); + Vector3 secondSize = new Vector3(5, 6, 7); + Vector3 thirdSize = new Vector3(8, 9, 10); + Vector3 fourthSize = new Vector3(11, 12, 13); + + Scene scene = new SceneHelpers().SetupScene(); + SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); + + g1.GroupResize(firstSize); + g1.GroupResize(secondSize); + + Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); + + g1.RootPart.Undo(); + + Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); + } + [Test] public void TestUndoBeyondAvailable() {