From 7796b90ebb434b4fa32757567b06e595dea4e97d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 23 Nov 2010 14:02:06 +0000 Subject: [PATCH 1/2] Fix some crashes caused by the addition of the CreatorData column --- OpenSim/Framework/Capabilities/Caps.cs | 1 + .../Services/Connectors/Inventory/XInventoryConnector.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 7b0e053c26..e7f2e132e2 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -967,6 +967,7 @@ namespace OpenSim.Framework.Capabilities InventoryItemBase item = new InventoryItemBase(); item.Owner = m_agentID; item.CreatorId = m_agentID.ToString(); + item.CreatorData = String.Empty; item.ID = inventoryItem; item.AssetID = asset.FullID; item.Description = assetDescription; diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index 88fbda355e..b3bfcc27df 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs @@ -302,6 +302,8 @@ namespace OpenSim.Services.Connectors public bool AddItem(InventoryItemBase item) { + if (item.CreatorData == null) + item.CreatorData = String.Empty; Dictionary ret = MakeRequest("ADDITEM", new Dictionary { { "AssetID", item.AssetID.ToString() }, @@ -335,6 +337,8 @@ namespace OpenSim.Services.Connectors public bool UpdateItem(InventoryItemBase item) { + if (item.CreatorData == null) + item.CreatorData = String.Empty; Dictionary ret = MakeRequest("UPDATEITEM", new Dictionary { { "AssetID", item.AssetID.ToString() }, @@ -558,7 +562,10 @@ namespace OpenSim.Services.Connectors item.InvType = int.Parse(data["InvType"].ToString()); item.Folder = new UUID(data["Folder"].ToString()); item.CreatorId = data["CreatorId"].ToString(); - item.CreatorData = data["CreatorData"].ToString(); + if (data.ContainsKey("CreatorData")) + item.CreatorData = data["CreatorData"].ToString(); + else + item.CreatorData = String.Empty; item.Description = data["Description"].ToString(); item.NextPermissions = uint.Parse(data["NextPermissions"].ToString()); item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString()); From 45b08a9ce306835dbd9493f4157a3a6e2e0d349c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 23 Nov 2010 00:31:09 +0100 Subject: [PATCH 2/2] Fix more potential nullrefs --- OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 23ae5b4547..22a718a354 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -600,8 +600,10 @@ namespace OpenSim.Server.Handlers.Asset ret["AssetType"] = item.AssetType.ToString(); ret["BasePermissions"] = item.BasePermissions.ToString(); ret["CreationDate"] = item.CreationDate.ToString(); - ret["CreatorId"] = item.CreatorId.ToString(); - ret["CreatorData"] = item.CreatorData.ToString(); + if (item.CreatorId != null) + ret["CreatorId"] = item.CreatorId.ToString(); + else + ret["CreatorId"] = String.Empty; ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); ret["Description"] = item.Description.ToString(); ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();