From 098650099e2f848d43e13176fcf1588221d518af Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 25 Dec 2021 16:42:28 -0800 Subject: [PATCH] Fix SQL playlist loader so it doesn't crash on an empty playlist --- Playlist/PlaylistLoader.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index e2e298e8d..d2971909b 100755 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -679,13 +679,11 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc //Clear the selection [playlistController setSelectionIndexes:[NSIndexSet indexSet]]; - NSArray* arrayFirst = [NSArray arrayWithObject:[entries objectAtIndex:0]]; - NSMutableArray* arrayRest = [entries mutableCopy]; - [arrayRest removeObjectAtIndex:0]; + if ([entries count]) + { + [self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:entries]; + } - [self performSelectorOnMainThread:@selector(syncLoadInfoForEntries:) withObject:arrayFirst waitUntilDone:YES]; - if ([arrayRest count]) - [self performSelectorInBackground:@selector(loadInfoForEntries:) withObject:arrayRest]; return entries; }