Browse Source

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.
pull/2595/head
Austin Wise 4 years ago
parent
commit
89101b593d
  1. 2
      ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

2
ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -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));

Loading…
Cancel
Save