From a41aea2d36e7f760ebabf979aa52866e3a3e9bf4 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 18 Feb 2023 10:43:38 +0000 Subject: [PATCH] Fix potential bug in get_selected_playlistrows() It was possible for the returned list to have embedded None objects --- app/playlists.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index 70293f1..b8421df 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -594,8 +594,8 @@ class PlaylistTab(QTableWidget): return [self._get_playlistrow_id(a) for a in self._get_selected_rows()] - def get_selected_playlistrows(self, - session: scoped_session) -> Optional[List]: + def get_selected_playlistrows( + self, session: scoped_session) -> Optional[List[PlaylistRows]]: """ Return a list of PlaylistRows of the selected rows """ @@ -603,7 +603,9 @@ class PlaylistTab(QTableWidget): plr_ids = self.get_selected_playlistrow_ids() if not plr_ids: return None - return [session.get(PlaylistRows, a) for a in plr_ids] + plrs = [session.get(PlaylistRows, a) for a in plr_ids] + + return [plr for plr in plrs if plr is not None] def insert_header(self, session: scoped_session, note: str, repaint: bool = True) -> None: