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 1/2] 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) { From a549c191da02e732afc560d9b4f45c8c82b29423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Wallstro=CC=88m?= Date: Mon, 11 Mar 2013 21:09:22 +0100 Subject: [PATCH 2/2] lint --- AppKit/CPCollectionView.j | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 98a2ea69b..58f39bd1f 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -1218,8 +1218,10 @@ Not supported. Use -collectionView:dataForItemsAtIndexes:fortype: - (void)_modifySelectionWithNewIndex:(int)anIndex direction:(int)aDirection expand:(BOOL)shouldExpand { var count = [[self items] count]; + if (count === 0) return; + anIndex = MIN(MAX(anIndex, 0), count - 1); if (_allowsMultipleSelection && shouldExpand)