Skip to content

Commit b340d7e

Browse files
committed
load error icon using cache
1 parent c5e3115 commit b340d7e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Wox/Image/ImageLoader.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ private static ImageSource LoadInternal(string path)
9393
bool imageInsideWoxDirectory = IsSubdirectory(parent1, subPath) || IsSubdirectory(parent2, subPath);
9494
if (normalImage && imageInsideWoxDirectory)
9595
{
96-
var bitmapImage = new BitmapImage(new Uri(path))
96+
image = new BitmapImage(new Uri(path))
9797
{
9898
DecodePixelHeight = 32,
9999
DecodePixelWidth = 32
100100
};
101-
image = bitmapImage;
102101
image.Freeze();
103102
return image;
104103
}
@@ -159,10 +158,16 @@ private static ImageSource LoadInternal(string path)
159158

160159
private static ImageSource GetErrorImage()
161160
{
162-
ShellFile shellFile = ShellFile.FromFilePath(Constant.ErrorIcon);
163-
// small is (32, 32), refer comment above
164-
ImageSource image = shellFile.Thumbnail.SmallBitmapSource;
165-
image.Freeze();
161+
ImageSource image = _cache.GetOrAdd(Constant.ErrorIcon, (_) =>
162+
{
163+
BitmapImage bitmap = new BitmapImage(new Uri(Constant.ErrorIcon))
164+
{
165+
DecodePixelHeight = 32,
166+
DecodePixelWidth = 32
167+
};
168+
bitmap.Freeze();
169+
return bitmap;
170+
});
166171
return image;
167172
}
168173

0 commit comments

Comments
 (0)