Fix a number of issues pointed out by @fredkiefer

This commit is contained in:
Gregory John Casamento 2024-08-18 17:25:47 -04:00
parent fbc0cd160b
commit 5befed5855
4 changed files with 22 additions and 19 deletions

View file

@ -44,7 +44,6 @@ APPKIT_EXPORT_CLASS
NSMapTable *_itemDict;
NSMutableArray *_items;
NSMutableArray *_expandedItems;
NSMutableArray *_selectedIndexPaths;
NSMapTable *_levelOfItems;
BOOL _autoResizesOutlineColumn;
BOOL _indentationMarkerFollowsCell;

View file

@ -3532,7 +3532,6 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
NSInteger endingColumn;
NSRect drawingRect;
NSInteger i;
id dataSource = [outlineView dataSource];
NSTableColumn *outlineTableColumn = [outlineView outlineTableColumn];
/* Using columnAtPoint: here would make it called twice per row per drawn

View file

@ -225,7 +225,6 @@ static NSImage *unexpandable = nil;
{
RELEASE(_items);
RELEASE(_expandedItems);
RELEASE(_selectedIndexPaths);
NSFreeMapTable(_itemDict);
NSFreeMapTable(_levelOfItems);
@ -1788,17 +1787,16 @@ Also returns the child index relative to this parent. */
- (NSIndexPath *) _indexPathForItem: (id)item
{
id rootItem = nil;
return [self _findIndexPathForItem: item
parentItem: rootItem];
parentItem: nil];
}
- (void) _indexPathsFromSelectedRows
- (NSArray *) _indexPathsFromSelectedRows
{
NSUInteger index = [_selectedRows firstIndex];
NSMutableArray *result = [[NSMutableArray alloc] init];
// Regenerate the array...
[_selectedIndexPaths removeAllObjects];
while (index != NSNotFound)
{
id item = [_items objectAtIndex: index];
@ -1813,10 +1811,12 @@ Also returns the child index relative to this parent. */
path = [self _indexPathForItem: item];
}
[_selectedIndexPaths addObject: path];
[result addObject: path];
index = [_selectedRows indexGreaterThanIndex: index];
}
return result;
}
/*
@ -1847,12 +1847,12 @@ Also returns the child index relative to this parent. */
forObject: observedObject];
if (theBinding != nil)
{
[self _indexPathsFromSelectedRows];
NSArray *paths = [self _indexPathsFromSelectedRows];
if ([observedObject respondsToSelector: @selector(setSelectionIndexPaths:)])
{
[observedObject setSelectionIndexPaths: _selectedIndexPaths];
[observedObject setSelectionIndexPaths: paths];
}
[theBinding reverseSetValue: _selectedIndexPaths];
[theBinding reverseSetValue: paths];
}
}
@ -2101,7 +2101,6 @@ Also returns the child index relative to this parent. */
64);
_items = [[NSMutableArray alloc] init];
_expandedItems = [[NSMutableArray alloc] init];
_selectedIndexPaths = [[NSMutableArray alloc] init];
_levelOfItems = NSCreateMapTable(keyCallBacks,
NSObjectMapValueCallBacks,
64);

View file

@ -161,7 +161,8 @@
if (YES == f)
{
[_selection_index_paths addObject: indexPath];
NSMutableArray *mutable_index_paths = [NSMutableArray arrayWithObject: indexPath];
ASSIGN(_selection_index_paths, mutable_index_paths);
}
return f;
@ -241,17 +242,21 @@
- (NSIndexPath *) selectionIndexPath
{
return [_selection_index_paths objectAtIndex: 0];
if ([_selection_index_paths count] > 0)
{
return [_selection_index_paths objectAtIndex: 0];
}
return nil;
}
- (NSArray *) selectionIndexPaths
{
return _selection_index_paths;
return [_selection_index_paths copy];
}
- (NSArray *) sortDescriptors
{
return _sortDescriptors;
return [_sortDescriptors copy];
}
- (NSString *) childrenKeyPath
@ -261,7 +266,7 @@
- (NSString *) countKeyPath
{
return _countKeyPath;;
return _countKeyPath;
}
- (NSString *) leafKeyPath
@ -274,6 +279,7 @@
NSIndexPath *p = [NSIndexPath indexPathWithIndex: 0];
id newObject = [self newObject];
[self insertObject: newObject atArrangedObjectIndexPath: p];
RELEASE(newObject);
}
- (IBAction) addChild: (id)sender
@ -295,7 +301,7 @@
{
if ([_selection_index_paths count] > 0)
{
NSIndexPath *p = [_selection_index_paths objectAtIndex: 0];
NSIndexPath *p = [self selectionIndexPath];
[self removeObjectAtArrangedObjectIndexPath: p];
}
}