OSDN Git Service

PrimWorkshop - Makes sure if decoding errors happen the gotImage.Set still happens
authorDouglas R. Miles <logicmoo@gmail.com>
Mon, 20 Feb 2012 08:05:30 +0000 (08:05 +0000)
committerDouglas R. Miles <logicmoo@gmail.com>
Mon, 20 Feb 2012 08:05:30 +0000 (08:05 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@1202 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Rendering/PrimWorkshop.cs

index 7067252..cce4da3 100644 (file)
@@ -1025,22 +1025,28 @@ namespace Radegast.Rendering
                 gotImage.Reset();
                 instance.Client.Assets.RequestImage(textureID, (TextureRequestState state, AssetTexture assetTexture) =>
                     {
-                        if (state == TextureRequestState.Finished)
+                        try
                         {
-                            ManagedImage mi;
-                            OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi);
-
-                            if (removeAlpha)
+                            if (state == TextureRequestState.Finished)
                             {
-                                if ((mi.Channels & ManagedImage.ImageChannels.Alpha) != 0)
+                                ManagedImage mi;
+                                OpenJPEG.DecodeToImage(assetTexture.AssetData, out mi);
+
+                                if (removeAlpha)
                                 {
-                                    mi.ConvertChannels(mi.Channels & ~ManagedImage.ImageChannels.Alpha);
+                                    if ((mi.Channels & ManagedImage.ImageChannels.Alpha) != 0)
+                                    {
+                                        mi.ConvertChannels(mi.Channels & ~ManagedImage.ImageChannels.Alpha);
+                                    }
                                 }
-                            }
 
-                            img = LoadTGAClass.LoadTGA(new MemoryStream(mi.ExportTGA()));
+                                img = LoadTGAClass.LoadTGA(new MemoryStream(mi.ExportTGA()));
+                            }
+                        }
+                        finally
+                        {
+                            gotImage.Set();                            
                         }
-                        gotImage.Set();
                     }
                 );
                 gotImage.WaitOne(30 * 1000, false);