diff --git a/AppKit/CPArrayController.j b/AppKit/CPArrayController.j index 99c181b22..9890840da 100644 --- a/AppKit/CPArrayController.j +++ b/AppKit/CPArrayController.j @@ -220,7 +220,7 @@ // We need to be in control of when notifications fire. _contentObject = value; - if (_clearsFilterPredicateOnInsertion) + if (_clearsFilterPredicateOnInsertion && _filterPredicate != nil) [self __setFilterPredicate:nil]; // Causes a _rearrangeObjects. else [self _rearrangeObjects]; diff --git a/Tests/AppKit/CPArrayControllerTest.j b/Tests/AppKit/CPArrayControllerTest.j index dfa3c1fdb..84506e5a8 100644 --- a/Tests/AppKit/CPArrayControllerTest.j +++ b/Tests/AppKit/CPArrayControllerTest.j @@ -1,5 +1,6 @@ @import +@import @implementation CPArrayControllerTest : OJTestCase { @@ -190,8 +191,7 @@ [arrayController setContent:newContent]; - [self assert:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 2)] equals:[arrayController selectionIndexes] - message:@"last object cannot be selected"]; + [self assert:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 2)] equals:[arrayController selectionIndexes] message:@"last object cannot be selected"]; } - (void)testContentBinding @@ -354,6 +354,16 @@ [self assert:@"Building 1" equals:[[self arrayController] valueForKeyPath:@"selection.department.building"]]; } +- (void)testArrangedObjectsNotEmptyAfterSetContentWhenClearsFilterOnInsertionIsTrue +{ + var arrayController = [[CPArrayController alloc] init]; + [arrayController setFilterPredicate:nil]; + [arrayController setClearsFilterPredicateOnInsertion:YES]; + [arrayController setContent:[CPArray arrayWithObject:@"a"]]; + + [self assertTrue:[[arrayController arrangedObjects] count] > 0]; +} + - (void)observeValueForKeyPath:keyPath ofObject:anActivity change:change