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 <kode54@gmail.com>
This commit is contained in:
parent
be0ccaffa2
commit
b480453886
1 changed files with 14 additions and 8 deletions
|
@ -100,11 +100,14 @@ static NSString *playlistSavedColumnsID = @"Playlist Saved Columns v0";
|
||||||
|
|
||||||
for(id column in updatedColumns) {
|
for(id column in updatedColumns) {
|
||||||
NSString *columnID = [column objectForKey:@"id"];
|
NSString *columnID = [column objectForKey:@"id"];
|
||||||
NSTableColumn *tableColumn = [columns objectAtIndex:[columnsList indexOfObject:columnID]];
|
NSUInteger index = [columnsList indexOfObject:columnID];
|
||||||
|
if(index != NSNotFound) {
|
||||||
|
NSTableColumn *tableColumn = [columns objectAtIndex:index];
|
||||||
[tableColumn setHidden:[[column objectForKey:@"hidden"] boolValue]];
|
[tableColumn setHidden:[[column objectForKey:@"hidden"] boolValue]];
|
||||||
[tableColumn setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
|
[tableColumn setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
|
||||||
[self addTableColumn:tableColumn];
|
[self addTableColumn:tableColumn];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
columns = [self tableColumns];
|
columns = [self tableColumns];
|
||||||
|
|
||||||
|
@ -151,11 +154,14 @@ static NSString *playlistSavedColumnsID = @"Playlist Saved Columns v0";
|
||||||
if(visibleTableColumns == 0) {
|
if(visibleTableColumns == 0) {
|
||||||
for(NSTableColumn *col in columns) {
|
for(NSTableColumn *col in columns) {
|
||||||
NSString *columnID = [col identifier];
|
NSString *columnID = [col identifier];
|
||||||
id column = [defaultColumns objectAtIndex:[defaultColumnList indexOfObject:columnID]];
|
NSUInteger index = [defaultColumnList indexOfObject:columnID];
|
||||||
|
if(index != NSNotFound) {
|
||||||
|
id column = [defaultColumns objectAtIndex:index];
|
||||||
[col setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
|
[col setWidth:[[column objectForKey:@"width"] unsignedIntegerValue]];
|
||||||
[col setHidden:[[column objectForKey:@"hidden"] boolValue]];
|
[col setHidden:[[column objectForKey:@"hidden"] boolValue]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableColumnsResized) name:NSTableViewColumnDidResizeNotification object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableColumnsResized) name:NSTableViewColumnDidResizeNotification object:nil];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableColumnsMoved) name:NSTableViewColumnDidMoveNotification object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableColumnsMoved) name:NSTableViewColumnDidMoveNotification object:nil];
|
||||||
|
|
Loading…
Reference in a new issue