From 89101b593dd420d7908bdf20518da9997305ce32 Mon Sep 17 00:00:00 2001 From: Austin Wise Date: Thu, 30 Dec 2021 20:42:18 -0800 Subject: [PATCH] Fix loading icons embedded as resources. When BitmapCacheOption.None is used, icons will not be loaded from the stream until they are needed to be displayed. In this case, the icon loading will be triggered when the text box is rendered from the UI thread. However by that time the steam object will have already been disposed. This results in no icons being visibile. The fix is to eager load the icons while the stream is still alive. An alterntive fix would be to defer disposing the stream to a later time or not dispose it at all. --- ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs index 95a606592..f886cf2b3 100644 --- a/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs @@ -59,7 +59,7 @@ namespace ICSharpCode.ILSpy.TreeNodes using var data = OpenStream(); if (data == null) return false; - IconBitmapDecoder decoder = new IconBitmapDecoder(data, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None); + IconBitmapDecoder decoder = new IconBitmapDecoder(data, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); foreach (var frame in decoder.Frames) { output.Write(String.Format("{0}x{1}, {2} bit: ", frame.PixelHeight, frame.PixelWidth, frame.Thumbnail.Format.BitsPerPixel));