Fix SQL playlist loader so it doesn't crash on an empty playlist

CQTexperiment
Christopher Snowhill 2021-12-25 16:42:28 -08:00
parent 9c9d71cd9c
commit 098650099e
1 changed files with 4 additions and 6 deletions

View File

@ -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;
}