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 <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2022-02-22 10:05:40 -05:00
parent 1296857189
commit ab6eb556ad
1 changed files with 4 additions and 1 deletions

View File

@ -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)