diff --git a/src/core/player.cpp b/src/core/player.cpp index 979c94726..4dd4084a5 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -190,15 +190,17 @@ void Player::NextItem(Engine::TrackChangeFlags change) { bool Player::HandleStopAfter() { if (app_->playlist_manager()->active()->stop_after_current()) { - app_->playlist_manager()->active()->StopAfter(-1); - + // Find what the next track would've been, and mark that one as current // so it plays next time the user presses Play. + app_->playlist_manager()->active()->StopAfter(-2); const int next_row = app_->playlist_manager()->active()->next_row(); if (next_row != -1) { app_->playlist_manager()->active()->set_current_row(next_row); } + app_->playlist_manager()->active()->StopAfter(-1); + Stop(); return true; } diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 2d1d9cb01..225bba4cc 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -106,6 +106,7 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager, favorite_(favorite), current_is_paused_(false), current_virtual_index_(-1), + is_stopping_next_(false), is_shuffled_(false), scrobble_point_(-1), lastfm_status_(LastFM_New), @@ -547,7 +548,6 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const { int Playlist::next_row(bool ignore_repeat_track) const { // Did we want to stop after this track? - if (stop_after_.isValid() && current_row() == stop_after_.row()) return -1; // Any queued items take priority if (!queue_->is_empty()) { @@ -629,8 +629,8 @@ void Playlist::set_current_row(int i) { old_current_item_index.sibling( old_current_item_index.row(), ColumnCount - 1)); } - - if (current_item_index_.isValid()) { + + if (current_item_index_.isValid() && !is_stopping_next_) { InformOfCurrentSongChange(); } @@ -1636,11 +1636,16 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(int row, int count) { void Playlist::StopAfter(int row) { QModelIndex old_stop_after = stop_after_; - if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1) + if ((stop_after_.isValid() && stop_after_.row() == row) || row == -1){ stop_after_ = QModelIndex(); - else + is_stopping_next_ = false; + } else if (row == -2) { + is_stopping_next_ = true; + } else{ stop_after_ = index(row, 0); - + is_stopping_next_ = false; + } + if (old_stop_after.isValid()) emit dataChanged( old_stop_after, diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 998f52acd..a5e45e086 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -402,6 +402,8 @@ signals: QPersistentModelIndex stop_after_; bool current_is_paused_; int current_virtual_index_; + + bool is_stopping_next_; bool is_shuffled_;