mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-30 15:33:35 +00:00
Fixed: CPArrayController could get out of bounds selections if a call to rearrangeObjects caused objects to disappear from the arranged set.
This commit is contained in:
@@ -209,7 +209,27 @@
|
||||
|
||||
- (void)rearrangeObjects
|
||||
{
|
||||
// Rearranging reapplies the selection criteria and may cause objects to disappear,
|
||||
// so take care of the selection.
|
||||
//
|
||||
// Sometimes rearrangeObjects is called by setContent which may cause two rounds of
|
||||
// selection preservation. This is okay because setContent temporarily clears the
|
||||
// selection and so this code below ends up preserving nothing in that case.
|
||||
var oldSelection = nil,
|
||||
oldSelectionIndexes = [[self selectionIndexes] copy];
|
||||
|
||||
if ([self preservesSelection])
|
||||
oldSelection = [self selectedObjects];
|
||||
|
||||
// Avoid out of bounds selections.
|
||||
_selectionIndexes = [CPIndexSet indexSet];
|
||||
|
||||
[self _setArrangedObjects:[self arrangeObjects:[self contentArray]]];
|
||||
|
||||
if (oldSelection)
|
||||
[self setSelectedObjects:oldSelection];
|
||||
else
|
||||
[self setSelectionIndexes:oldSelectionIndexes];
|
||||
}
|
||||
|
||||
- (void)_setArrangedObjects:(id)value
|
||||
|
||||
Reference in New Issue
Block a user