From 24e2ae57f09bef42d11a0c69a31fcf46a943707b Mon Sep 17 00:00:00 2001 From: Kieran Bond Date: Fri, 24 Jan 2020 10:01:25 +0000 Subject: [PATCH] Ensured closing of API on close Added a string null check in API requestor --- MiniSpotify/MiniSpotify/Source/APIRequestor.cs | 2 +- MiniSpotify/MiniSpotify/Source/MainWindow.xaml.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MiniSpotify/MiniSpotify/Source/APIRequestor.cs b/MiniSpotify/MiniSpotify/Source/APIRequestor.cs index 519bdf4..f8e0dfb 100644 --- a/MiniSpotify/MiniSpotify/Source/APIRequestor.cs +++ b/MiniSpotify/MiniSpotify/Source/APIRequestor.cs @@ -280,7 +280,7 @@ public bool SkipSongPlayback(bool a_nextSong = true) public string GetSongArtwork(string a_trackID) { - if (m_spotifyWebAPI != null) + if (m_spotifyWebAPI != null && !string.IsNullOrEmpty(a_trackID)) { return m_spotifyWebAPI.GetTrack(a_trackID).Album.Images[0].Url; } diff --git a/MiniSpotify/MiniSpotify/Source/MainWindow.xaml.cs b/MiniSpotify/MiniSpotify/Source/MainWindow.xaml.cs index 9456a9e..443db20 100644 --- a/MiniSpotify/MiniSpotify/Source/MainWindow.xaml.cs +++ b/MiniSpotify/MiniSpotify/Source/MainWindow.xaml.cs @@ -37,6 +37,8 @@ public MainWindow() APIRequestor.Instance.m_onAPIPolled += UpdateUI; LocationChanged += UpdateEditWindowPosition; + + Closing += (e, f) => APIRequestor.Instance.Close(); } public void UpdateUI(FullTrack a_latestTrack = null)