From fd59088528481d25615579a8a32968b057c6f6c2 Mon Sep 17 00:00:00 2001 From: AT <14300910+theClueless@users.noreply.github.com> Date: Fri, 3 Jan 2020 22:33:00 +0200 Subject: [PATCH] made data images freeze as well --- Wox.Infrastructure/Image/ImageLoader.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Wox.Infrastructure/Image/ImageLoader.cs b/Wox.Infrastructure/Image/ImageLoader.cs index 59a7a24fb4..528900ce7c 100644 --- a/Wox.Infrastructure/Image/ImageLoader.cs +++ b/Wox.Infrastructure/Image/ImageLoader.cs @@ -100,7 +100,9 @@ namespace Wox.Infrastructure.Image if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { - return new ImageResult(new BitmapImage(new Uri(path)), ImageType.Data); + var imageSource = new BitmapImage(new Uri(path)); + imageSource.Freeze(); + return new ImageResult(imageSource, ImageType.Data); } if (!Path.IsPathRooted(path)) @@ -181,7 +183,7 @@ namespace Wox.Infrastructure.Image { // we need to get image hash string hash = EnableImageHash ? _hashGenerator.GetHashFromImage(img) : null; if (hash != null) - { + { if (GuidToKey.TryGetValue(hash, out string key)) { // image already exists img = ImageCache[key]; @@ -195,7 +197,7 @@ namespace Wox.Infrastructure.Image // update cache ImageCache[path] = img; } - + return img; }