macosx: Avoid crashing upon clicking collection view item when receiving nil index path

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2024-05-11 17:25:31 +08:00 committed by Jean-Baptiste Kempf
parent f3693fe723
commit f54dc525de
1 changed files with 4 additions and 0 deletions

View File

@ -297,6 +297,10 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
[self.collectionView.dataSource conformsToProtocol:@protocol(VLCLibraryCollectionViewDataSource)]) {
NSObject<VLCLibraryCollectionViewDataSource> * const dataSource = (NSObject<VLCLibraryCollectionViewDataSource> *)self.collectionView.dataSource;
NSIndexPath * const indexPath = [dataSource indexPathForLibraryItem:self.representedItem.item];
if (indexPath == nil) {
return;
}
NSSet<NSIndexPath *> * const indexPathSet = [NSSet setWithObject:indexPath];
[self.collectionView deselectItemsAtIndexPaths:indexPathSet];