From 1513ad96d886531d3a75429dbe0077b600db06ad Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Fri, 26 Jul 2024 11:38:33 +0100 Subject: [PATCH] Fix track times bug When update_track_times runs, it looks as track_sequence.current and .next, but didn't check that those tracks referred to the current playlist, which could cause a KeyError. Fixes #252 --- app/playlistmodel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/playlistmodel.py b/app/playlistmodel.py index d9a3015..538cd6a 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -1109,7 +1109,7 @@ class PlaylistModel(QAbstractTableModel): track_sequence.current, track_sequence.previous, ]: - if ts and ts.row_number: + if ts and ts.playlist_id == self.playlist_id and ts.row_number: plr = session.get(PlaylistRows, ts.plr_id) if plr and plr.plr_rownum != ts.row_number: ts.row_number = plr.plr_rownum @@ -1472,7 +1472,7 @@ class PlaylistModel(QAbstractTableModel): current_track_row = None next_track_row = None - if track_sequence.current: + if track_sequence.current and track_sequence.current.playlist_id == self.playlist_id: current_track_row = track_sequence.current.row_number # Update current track details now so that they are available # when we deal with next track row which may be above current @@ -1481,7 +1481,7 @@ class PlaylistModel(QAbstractTableModel): update_rows, track_sequence.current.start_time ) - if track_sequence.next: + if track_sequence.next and track_sequence.next.playlist_id == self.playlist_id: next_track_row = track_sequence.next.row_number for row_number in range(row_count):