From 461e650e054faaffe2e6f006f02ff07a0cad99ae Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 3 May 2016 23:36:47 +0100 Subject: [PATCH] fix missing image cache --- Wox.Infrastructure/Image/ImageLoader.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Wox.Infrastructure/Image/ImageLoader.cs b/Wox.Infrastructure/Image/ImageLoader.cs index ae5aab337a..7a0b1e40c0 100644 --- a/Wox.Infrastructure/Image/ImageLoader.cs +++ b/Wox.Infrastructure/Image/ImageLoader.cs @@ -130,43 +130,42 @@ namespace Wox.Infrastructure.Image if (string.IsNullOrEmpty(path)) { image = ImageSources[ErrorIcon]; + _cache.Add(ErrorIcon); } else if (ImageSources.ContainsKey(path)) { image = ImageSources[path]; + _cache.Add(path); } else { - string ext = Path.GetExtension(path).ToLower(); if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { image = new BitmapImage(new Uri(path)); - ImageSources[path] = image; } else if (Path.IsPathRooted(path)) { if (Directory.Exists(path)) { image = ShellIcon(path); - ImageSources[path] = image; } else if (File.Exists(path)) { - if (ImageExtions.Contains(ext)) + var externsion = Path.GetExtension(path).ToLower(); + if (ImageExtions.Contains(externsion)) { image = new BitmapImage(new Uri(path)); - ImageSources[path] = image; } else { image = AssociatedIcon(path); - ImageSources[path] = image; } } else { image = ImageSources[ErrorIcon]; + path = ErrorIcon; } } else @@ -175,13 +174,16 @@ namespace Wox.Infrastructure.Image if (File.Exists(defaultDirectoryPath)) { image = new BitmapImage(new Uri(defaultDirectoryPath)); - ImageSources[path] = image; } else { image = ImageSources[ErrorIcon]; + path = ErrorIcon; } } + + ImageSources[path] = image; + _cache.Add(path); } return image; }