From 9cdd9e215ccb250992b82e229a9930c2648f827c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Sep 2008 21:32:45 +0000 Subject: * Patch http://opensimulator.org/mantis/view.php?id=2172 * Patch attached that adds the check for uninitialized appearance when inventory items are received and processed. Also attempts to ensure that appearance is initialized even when the profile cache has not been built. * This will not fix the race condition, but should at least remove the unhandled exception that is being reported in Mantis 0002126. * Thanks cmickeyb --- OpenSim/Region/Environment/Scenes/Scene.cs | 17 ++++++++--------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5b58804..da76ab8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2382,24 +2382,23 @@ namespace OpenSim.Region.Environment.Scenes /// public void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance) { - appearance = null; // VS needs this line, mono doesn't + appearance = new AvatarAppearance(); try { - if (m_AvatarFactory == null || - !m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance)) + if (m_AvatarFactory != null) { - m_log.Warn("[APPEARANCE]: Appearance not found, creating default"); - appearance = new AvatarAppearance(); + if (m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance)) + return; } } catch (Exception e) { - m_log.ErrorFormat( - "[APPERANCE]: Problem when fetching appearance for avatar {0}, {1}, using default. {2}", - client.Name, client.AgentId, e); - appearance = new AvatarAppearance(); + m_log.ErrorFormat("[APPEARANCE]: Problem fetching appearance for avatar {0}, {1}, {2}", + client.Name, client.AgentId, e.ToString()); } + m_log.Warn("[APPEARANCE]: Appearance not found, returning default"); + } /// diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index abda63e..ff043fb 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -2911,19 +2911,33 @@ namespace OpenSim.Region.Environment.Scenes private void ItemReceived(UUID itemID) { + if (null == m_appearance) + { + m_log.Warn("[ATTACHMENT] Appearance has not been initialized"); + return; + } + int attachpoint = m_appearance.GetAttachpoint(itemID); if (attachpoint == 0) return; UUID asset = m_appearance.GetAttachedAsset(attachpoint); - if (asset == UUID.Zero) // We have just logged in + if (UUID.Zero == asset) // We have just logged in { m_log.InfoFormat("[ATTACHMENT] Rez attachment {0}", itemID.ToString()); - // Rez from inventory - m_scene.RezSingleAttachment(ControllingClient, itemID, - (uint)attachpoint, 0, 0); + try + { + // Rez from inventory + m_scene.RezSingleAttachment(ControllingClient, itemID, + (uint)attachpoint, 0, 0); + } + catch (Exception e) + { + m_log.ErrorFormat("[ATTACHMENT] Unable to rez attachment: {0}", e.ToString()); + } + return; } -- cgit v1.1