From ab6eb556ada2f3d798ab389d6d1260149f51df84 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 22 Feb 2022 10:05:40 -0500 Subject: [PATCH] db: Fix track_adjusts_current() when the track has been removed In this case, the call to get_track_index() returns None which can't be used for the comparisons we're doing. Make sure we handle the None result explicitely. Signed-off-by: Anna Schumaker --- db/playlist.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/playlist.py b/db/playlist.py index e26bafc..63936f0 100644 --- a/db/playlist.py +++ b/db/playlist.py @@ -60,7 +60,10 @@ class Playlist(GObject.GObject): return cur.fetchone()[1] - 1 def track_adjusts_current(self, track): - return self.current > -1 and self.get_track_index(track) <= self.current + if self.current > -1: + if (index := self.get_track_index(track)) != None: + return index <= self.current + return False def add_track(self, track): self.emit("track-added", track)