From 1598f9d1790d18f0ebd78bddc088b6e57829aca5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 20 Jul 2012 11:54:59 +0200 Subject: Fix the order of operations on detach. The object must always be serialized while still in the scene to avoid losing important script state. DeleteSceneObject can not be called before doing this! --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 394b90a..f073c4a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -757,18 +757,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero); sp.RemoveAttachment(so); - // We can only remove the script instances from the script engine after we've retrieved their xml state - // when we update the attachment item. - m_scene.DeleteSceneObject(so, false, false); - // Prepare sog for storage so.AttachedAvatar = UUID.Zero; so.RootPart.SetParentLocalId(0); so.IsAttachment = false; - so.AbsolutePosition = so.RootPart.AttachedPos; + + // We cannot use AbsolutePosition here because that would + // attempt to cross the prim as it is detached + so.ForEachPart(x => { x.GroupPosition = so.RootPart.AttachedPos; }); UpdateKnownItem(sp, so, true); - so.RemoveScriptInstances(true); + + // This MUST happen AFTER serialization because it will + // either stop or remove the scripts. Both will cause scripts + // to be serialized in a stopped state with the true run + // state already lost. + m_scene.DeleteSceneObject(so, false, true); } protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( -- cgit v1.1