From b33da2538ed728bdc97cca20ada36913097160b0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 16 Jan 2008 20:27:12 +0000 Subject: * Fix mantis 345 - it is now possible to duplicate prims directly in the region again without breakage * This includes their inventories * Also, this revision properly synchronizes prim inventory crud. --- OpenSim/Framework/TaskInventoryItem.cs | 61 +++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/TaskInventoryItem.cs') diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 6e163a9..3009259 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -36,7 +36,13 @@ using System; namespace OpenSim.Framework { - public class TaskInventoryDictionary : Dictionary, IXmlSerializable + /// + /// A dictionary for task inventory. + /// + /// This class is not thread safe. Callers must synchronize on Dictionary methods. + /// + public class TaskInventoryDictionary : Dictionary, + ICloneable, IXmlSerializable { private static XmlSerializer tiiSerializer = new XmlSerializer(typeof(TaskInventoryItem)); @@ -86,19 +92,38 @@ namespace OpenSim.Framework // see IXmlSerializable public void WriteXml(XmlWriter writer) { - foreach (TaskInventoryItem item in Values) + lock (this) { - tiiSerializer.Serialize(writer, item); + foreach (TaskInventoryItem item in Values) + { + tiiSerializer.Serialize(writer, item); + } } //tiiSerializer.Serialize(writer, Values); } + + // see ICloneable + public Object Clone() + { + TaskInventoryDictionary clone = new TaskInventoryDictionary(); + + lock (this) + { + foreach (LLUUID uuid in Keys) + { + clone.Add(uuid, (TaskInventoryItem)this[uuid].Clone()); + } + } + + return clone; + } } /// /// Represents an item in a task inventory /// - public class TaskInventoryItem + public class TaskInventoryItem : ICloneable { /// /// XXX This should really be factored out into some constants class. @@ -141,17 +166,7 @@ namespace OpenSim.Framework String.Empty, "lsltext", String.Empty - }; - - /// - /// Reset the LLUUIDs for this item. - /// - /// The new part ID to which this item belongs - public void ResetIDs(LLUUID partID) - { - ItemID = LLUUID.Random(); - ParentPartID = partID; - } + }; public LLUUID ItemID = LLUUID.Zero; public LLUUID ParentID = LLUUID.Zero; //parent folder id @@ -175,5 +190,21 @@ namespace OpenSim.Framework public uint CreationDate = 0; public LLUUID ParentPartID = LLUUID.Zero; + + /// + /// Reset the LLUUIDs for this item. + /// + /// The new part ID to which this item belongs + public void ResetIDs(LLUUID partID) + { + ItemID = LLUUID.Random(); + ParentPartID = partID; + } + + // See ICloneable + public Object Clone() + { + return MemberwiseClone(); + } } } -- cgit v1.1