From 653aaa05c7b03f3be83d401f05baf5a705c8eb76 Mon Sep 17 00:00:00 2001 From: Michael Cortez Date: Tue, 23 Jan 2007 22:30:33 +0000 Subject: [PATCH] Try preventing a possible race condition in AppearanceManager when sending an AgentSetAppearance. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@889 52acb1d6-8a22-11de-b505-999d5b087335 --- .../AssetSystem/AppearanceManager.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libsecondlife-cs/AssetSystem/AppearanceManager.cs b/libsecondlife-cs/AssetSystem/AppearanceManager.cs index 44af6d6c..25386850 100644 --- a/libsecondlife-cs/AssetSystem/AppearanceManager.cs +++ b/libsecondlife-cs/AssetSystem/AppearanceManager.cs @@ -301,9 +301,12 @@ namespace libsecondlife.AssetSystem AgentTextureEntry.CreateFace(texture.Key).TextureID = texture.Value; } - foreach (KeyValuePair kvp in wearableAsset.Parameters) + lock (AgentAppearanceParams) { - AgentAppearanceParams[kvp.Key] = kvp.Value; + foreach (KeyValuePair kvp in wearableAsset.Parameters) + { + AgentAppearanceParams[kvp.Key] = kvp.Value; + } } } catch (Exception e) @@ -389,12 +392,15 @@ namespace libsecondlife.AssetSystem float percentage = 0; byte packetVal = 0; - foreach (KeyValuePair kvp in AgentAppearanceParams) + lock (AgentAppearanceParams) { - packetIdx = AppearanceManager.GetAgentSetAppearanceIndex(kvp.Key) - 1; //TODO/FIXME: this should be zero indexed, not 1 based. + foreach (KeyValuePair kvp in AgentAppearanceParams) + { + packetIdx = AppearanceManager.GetAgentSetAppearanceIndex(kvp.Key) - 1; //TODO/FIXME: this should be zero indexed, not 1 based. - VisualParam vp = libsecondlife.VisualParams.Params[kvp.Key]; - VisualParams[packetIdx] = Helpers.FloatToByte(kvp.Value, vp.MinValue, vp.MaxValue); + VisualParam vp = libsecondlife.VisualParams.Params[kvp.Key]; + VisualParams[packetIdx] = Helpers.FloatToByte(kvp.Value, vp.MinValue, vp.MaxValue); + } } return VisualParams;