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.
This commit is contained in:
parent
5e45f59e2c
commit
55e5eab157
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user