dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
675 stars 26 forks source link

Crash when removing everything from the currently playing track to the end of the play queue while playing #270

Closed dweymouth closed 7 months ago

dweymouth commented 8 months ago

Repro:

  1. Queue some tracks and play one somewhere in the middle of the play queue
  2. Select everything from the currently playing track until the end of the queue and remove it
panic: runtime error: index out of range [-1]

goroutine 43 [running]:
github.com/dweymouth/supersonic/backend.(*PlaybackManager).NowPlaying(...)
    /Users/drew.weymouth/supersonic/backend/playbackmanager.go:127
github.com/dweymouth/supersonic/backend.(*PlaybackManager).invokeOnSongChangeCallbacks(0x14000374500)
    /Users/drew.weymouth/supersonic/backend/playbackmanager.go:397 +0x128
github.com/dweymouth/supersonic/backend.(*PlaybackManager).RemoveTracksFromQueue(0x14000374500, {0x1400688f4a0, 0x6, 0x6})
    /Users/drew.weymouth/supersonic/backend/playbackmanager.go:297 +0x320
github.com/dweymouth/supersonic/ui/browsing.(*NowPlayingPage).onRemoveSelectedFromQueue(0x14005508000)
    /Users/drew.weymouth/supersonic/ui/browsing/nowplayingpage.go:196 +0x50
fyne.io/fyne/v2/widget.(*menuItem).trigger(0x1400483e960)
    /Users/drew.weymouth/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20231103053003-b6f79d3c81cd/widget/menu_item.go:207 +0x40
fyne.io/fyne/v2/widget.(*menuItem).Tapped(0x1400483e901?, 0x1400045c09c?)
    /Users/drew.weymouth/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20231103053003-b6f79d3c81cd/widget/menu_item.go:153 +0x60
fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseClickedHandleTapDoubleTap.func1()
    /Users/drew.weymouth/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20231103053003-b6f79d3c81cd/internal/driver/glfw/window.go:649 +0x2c
fyne.io/fyne/v2/internal/driver/common.(*Window).RunEventQueue(0x0?)
    /Users/drew.weymouth/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20231103053003-b6f79d3c81cd/internal/driver/common/window.go:35 +0x3c
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
    /Users/drew.weymouth/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20231103053003-b6f79d3c81cd/internal/driver/glfw/window.go:959 +0x144