Skip to content

Commit

Permalink
Resource disposal improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 21, 2024
1 parent 34dbfe4 commit ca4d988
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/PicView.Avalonia/Navigation/Preloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ public async Task<bool> RefreshFileInfo(int index, List<string> list)
/// </summary>
public void Clear()
{
foreach (var item in _preLoadList.Values)
{
if (item.ImageModel.Image is Bitmap img)
{
img.Dispose();
}
}
_preLoadList.Clear();
}

Expand Down Expand Up @@ -401,7 +408,7 @@ private void Dispose(bool disposing)

if (disposing)
{
_preLoadList.Clear();
Clear();
}
_disposed = true;
}
Expand Down

0 comments on commit ca4d988

Please sign in to comment.