From 7e823d435df7bf3ba080e7d3b990f22d7b5d6351 Mon Sep 17 00:00:00 2001 From: James Coliz Date: Thu, 18 Jul 2024 17:24:28 -0700 Subject: [PATCH] fix(ui): Displose of image streams after loading Fixes #38 --- LogoSlideMaker.WinUi/Services/BitmapCache.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LogoSlideMaker.WinUi/Services/BitmapCache.cs b/LogoSlideMaker.WinUi/Services/BitmapCache.cs index 5cf6245..9fae533 100644 --- a/LogoSlideMaker.WinUi/Services/BitmapCache.cs +++ b/LogoSlideMaker.WinUi/Services/BitmapCache.cs @@ -128,6 +128,11 @@ private async Task LoadBitmapAsync(ICanvasResourceCreator resource var randomAccessStream = pngStream.AsRandomAccessStream(); var result = await CanvasBitmap.LoadAsync(resourceCreator, randomAccessStream); + if (stream is not null) + { + await stream.DisposeAsync(); + } + return result; } else @@ -135,6 +140,11 @@ private async Task LoadBitmapAsync(ICanvasResourceCreator resource var randomAccessStream = stream.AsRandomAccessStream(); var result = await CanvasBitmap.LoadAsync(resourceCreator, randomAccessStream); + if (stream is not null) + { + await stream.DisposeAsync(); + } + return result; } }