From 2bf244209637608b00adf36780d3f1fbd2f9901c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Wallstro=CC=88m?= Date: Sun, 10 Mar 2013 17:38:08 +0100 Subject: [PATCH] Fixed: Using keyboard navigation in empty CPCollectionView threw exception. --- AppKit/CPCollectionView.j | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index caa414c96..98a2ea69b 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -1217,7 +1217,10 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype: - (void)_modifySelectionWithNewIndex:(int)anIndex direction:(int)aDirection expand:(BOOL)shouldExpand { - anIndex = MIN(MAX(anIndex, 0), [[self items] count] - 1); + var count = [[self items] count]; + if (count === 0) + return; + anIndex = MIN(MAX(anIndex, 0), count - 1); if (_allowsMultipleSelection && shouldExpand) {