Fixed memory leak issue with song image source not getting disposed. Added playbackbar configuration button.

This commit is contained in:
2025-03-05 22:08:46 -05:00
parent 9fc8791ad1
commit 9890236710
4 changed files with 34 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace Harmonia.UI.ViewModels;
public class PlayingSongInfoViewModel : ViewModelBase
public class PlayingSongInfoViewModel : ViewModelBase, IDisposable
{
private readonly IAudioPlayer _audioPlayer;
private readonly IAudioImageCache _audioImageCache;
@@ -41,6 +41,7 @@ public class PlayingSongInfoViewModel : ViewModelBase
}
private set
{
_songImageSource?.Dispose();
_songImageSource = value;
OnPropertyChanged();
}
@@ -88,4 +89,10 @@ public class PlayingSongInfoViewModel : ViewModelBase
using MemoryStream stream = new(songPictureInfo.Data);
SongImageSource = new(stream);
}
public void Dispose()
{
SongImageSource?.Dispose();
GC.SuppressFinalize(this);
}
}