From 55e5eab1574b78996254d4254c4c8e6c718c883f Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 13 Mar 2015 14:12:19 +0100 Subject: [PATCH] Fix Race-Condition in SpotifyClient that caused playback to break. QList.removeAll calls the destructor for the elements in the list. This caused `req` to be initialized in `SpotifyClient::TryPlaybackAgain()`. Therefore, spotify method calls might crash because the pointers are invalid. This commit moves the `pending_playback_requests_.removeAll` to the end of the method to ensure `req` is accessible all the time. --- ext/clementine-spotifyblob/spotifyclient.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/clementine-spotifyblob/spotifyclient.cpp b/ext/clementine-spotifyblob/spotifyclient.cpp index d9135bbc5..4527bc24b 100644 --- a/ext/clementine-spotifyblob/spotifyclient.cpp +++ b/ext/clementine-spotifyblob/spotifyclient.cpp @@ -942,9 +942,6 @@ void SpotifyClient::TryPlaybackAgain(const PendingPlaybackRequest& req) { return; } - // Remove this from the pending list now - pending_playback_requests_.removeAll(req); - // Load the track sp_error error = sp_session_player_load(session_, req.track_); if (error != SP_ERROR_OK) { @@ -965,6 +962,9 @@ void SpotifyClient::TryPlaybackAgain(const PendingPlaybackRequest& req) { sp_session_player_play(session_, true); sp_link_release(req.link_); + + // Remove this from the pending list now + pending_playback_requests_.removeAll(req); } void SpotifyClient::SendPlaybackError(const QString& error) {