From 2ccd95b276b41caefeb952bdcfcf14fca47569bd Mon Sep 17 00:00:00 2001 From: joren Date: Tue, 24 Mar 2026 00:43:08 +0100 Subject: [PATCH] fix: play next track correctly skips to queued track MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit advance() was removing the playNext item then calling current(), which fell back to m_queue[m_index] — the same track already playing. Fix: use takeFirst() and return that item directly, only advancing m_index when the playNext list is empty. Co-Authored-By: Claude Sonnet 4.6 --- src/playqueue.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/playqueue.hpp b/src/playqueue.hpp index 8727778..bbf521f 100644 --- a/src/playqueue.hpp +++ b/src/playqueue.hpp @@ -124,14 +124,17 @@ public: return static_cast(current()["id"].toDouble()); } - /// Advance and return the new current track. Returns {} at end of queue. + /// Advance and return the track to play next. Returns {} at end of queue. QJsonObject advance() { if (!m_playNext.isEmpty()) { - m_playNext.removeFirst(); - } else { - ++m_index; + // Return the playNext item directly — do NOT call current() after + // removal, as that would fall back to the already-playing m_index track. + const QJsonObject next = m_playNext.takeFirst(); + emit queueChanged(); + return next; } + ++m_index; emit queueChanged(); return current(); }