From 0d289e47ab8e6d3ead21254602f70aeba010bfd6 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 15 Feb 2025 14:09:27 -0800 Subject: [PATCH] Bug Fix: Add safety checks to playlist columns Playlist column setup needed a couple of safety checks to prevent crashes from happening. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistView.m | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Playlist/PlaylistView.m b/Playlist/PlaylistView.m index 93462056f..fade50027 100644 --- a/Playlist/PlaylistView.m +++ b/Playlist/PlaylistView.m @@ -100,12 +100,15 @@ static NSString *playlistSavedColumnsID = @"Playlist Saved Columns v0"; 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) { @@ -151,9 +154,12 @@ static NSString *playlistSavedColumnsID = @"Playlist Saved Columns v0"; 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]]; + } } }