From 7c04d278753c717a91e5eeb3086d62c771b03f05 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 1 Nov 2008 21:50:07 +0000
Subject: * Introduce an IsAttachment property on the group level (which just
 returns false if the group is already deleted) * This is to avoid repetitive
 null checks - I'm beginning to think that blasting away the root part on
 object deletion is actually a bad move.  Perhaps we should leave it around
 and let the client ignore any superfluous packets (which it may well do
 anyway), since we're constantly exposing a race condition

---
 .../World/Archiver/ArchiveWriteRequestPreparation.cs |  2 +-
 .../Region/Environment/Scenes/SceneObjectGroup.cs    | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 8c623b1..b520642 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -276,7 +276,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
                 {
                     SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
                     
-                    if (sceneObject.RootPart != null && !sceneObject.RootPart.IsAttachment)
+                    if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
                         sceneObjects.Add((SceneObjectGroup)entity);
                 }
             }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index f4b6685..a94e592 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -93,6 +93,26 @@ namespace OpenSim.Region.Environment.Scenes
         /// since the group's last persistent backup
         /// </summary>
         public bool HasGroupChanged = false;
+        
+        /// <value>
+        /// Is this scene object acting as an attachment?
+        /// 
+        /// We return false if the group has already been deleted.
+        ///  
+        /// TODO: At the moment set must be done on the part itself.  There may be a case for doing it here since I
+        /// presume either all or no parts in a linkset can be part of an attachment (in which
+        /// case the value would get proprogated down into all the descendent parts).
+        /// </value>
+        public bool IsAttachment
+        {
+            get
+            {
+                if (!IsDeleted)
+                    return m_rootPart.IsAttachment;
+                
+                return false;
+            }
+        }
 
         public float scriptScore = 0f;
 
-- 
cgit v1.1