mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-23 15:27:03 -04:00
Dispose thumbnail streams
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media.Imaging;
|
||||
using WowUp.WPF.Utilities;
|
||||
@@ -23,6 +24,8 @@ namespace WowUp.WPF.Converters
|
||||
|
||||
if (value is Uri uri)
|
||||
{
|
||||
MemoryStream imageStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
BitmapImage thumbnail = new BitmapImage();
|
||||
@@ -31,7 +34,8 @@ namespace WowUp.WPF.Converters
|
||||
|
||||
if (uri.IsFile)
|
||||
{
|
||||
thumbnail.StreamSource = FileUtilities.GetMemoryStreamFromFile(uri.LocalPath);
|
||||
imageStream = FileUtilities.GetMemoryStreamFromFile(uri.LocalPath);
|
||||
thumbnail.StreamSource = imageStream;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -46,6 +50,11 @@ namespace WowUp.WPF.Converters
|
||||
{
|
||||
Log.Error(ex, "Failed to create bitmap image");
|
||||
}
|
||||
finally
|
||||
{
|
||||
imageStream?.Close();
|
||||
imageStream?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -12,7 +12,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>True</PublishSingleFile>
|
||||
<PublishReadyToRun>True</PublishReadyToRun>
|
||||
<PublishReadyToRun>False</PublishReadyToRun>
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user