Skip to content

Commit

Permalink
Bug Fix: Add safety checks to playlist columns
Browse files Browse the repository at this point in the history
Playlist column setup needed a couple of safety checks to prevent
crashes from happening.

Signed-off-by: Christopher Snowhill <[email protected]>
  • Loading branch information
kode54 committed Feb 15, 2025
1 parent abf77a7 commit 0d289e4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Playlist/PlaylistView.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ - (void)awakeFromNib {

for(id column in updatedColumns) {
NSString *columnID = [column objectForKey:@"id"];
NSTableColumn *tableColumn = [columns objectAtIndex:[columnsList indexOfObject:columnID]];
[tableColumn setHidden:[[column objectForKey:@"hidden"] boolValue]];
[tableColumn setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
[self addTableColumn:tableColumn];
NSUInteger index = [columnsList indexOfObject:columnID];
if(index != NSNotFound) {
NSTableColumn *tableColumn = [columns objectAtIndex:index];
[tableColumn setHidden:[[column objectForKey:@"hidden"] boolValue]];
[tableColumn setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
[self addTableColumn:tableColumn];
}
}

columns = [self tableColumns];

for(NSTableColumn *col in columns) {
Expand Down Expand Up @@ -151,9 +154,12 @@ - (void)awakeFromNib {
if(visibleTableColumns == 0) {
for(NSTableColumn *col in columns) {
NSString *columnID = [col identifier];
id column = [defaultColumns objectAtIndex:[defaultColumnList indexOfObject:columnID]];
[col setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
[col setHidden:[[column objectForKey:@"hidden"] boolValue]];
NSUInteger index = [defaultColumnList indexOfObject:columnID];
if(index != NSNotFound) {
id column = [defaultColumns objectAtIndex:index];
[col setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
[col setHidden:[[column objectForKey:@"hidden"] boolValue]];
}
}
}

Expand Down

0 comments on commit 0d289e4

Please sign in to comment.