From c98fb267899206e624285b14073d478c0a5224a2 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Sat, 24 May 2008 03:19:57 +0000
Subject: * an attempt to resolve the teleport + attachment = crash

---
 OpenSim/Region/Environment/Scenes/ScenePresence.cs | 23 ++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index a692b33..b367ce4 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -93,6 +93,8 @@ namespace OpenSim.Region.Environment.Scenes
         private float m_sitAvatarHeight = 2.0f;
         private float m_godlevel = 0;
 
+        private bool m_attachmentsTransported = false;
+
         private bool m_invulnerable = true;
 
         private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3();
@@ -1951,12 +1953,23 @@ namespace OpenSim.Region.Environment.Scenes
         {
             lock (m_attachments)
             {
-                foreach (SceneObjectGroup grp in m_attachments)
+                if (!m_attachmentsTransported)
                 {
-                    // ControllingClient may be null at this point!
-                    m_scene.m_innerScene.DetachSingleAttachmentToInv(grp.GetFromAssetID(), ControllingClient);
+                    try
+                    {
+                        foreach (SceneObjectGroup grp in m_attachments)
+                        {
+                            // ControllingClient may be null at this point!
+                            m_scene.m_innerScene.DetachSingleAttachmentToInv(grp.GetFromAssetID(), ControllingClient);
+                        }
+                    }
+                    catch (InvalidOperationException)
+                    {
+                        m_log.Info("[CLIENT]: Couldn't save attachments. :(");
+                    }
+                    m_attachments.Clear();
+                    
                 }
-                m_attachments.Clear();
             }
             lock (m_knownPrimUUID)
             {
@@ -2016,8 +2029,10 @@ namespace OpenSim.Region.Environment.Scenes
 
         public void CrossAttachmentsIntoNewRegion(ulong regionHandle)
         {
+            m_attachmentsTransported = true;
             lock (m_attachments)
             {
+                
                 foreach (SceneObjectGroup gobj in m_attachments)
                 {
                     // If the prim group is null then something must have happened to it!
-- 
cgit v1.1