[vlc-commits] macosx: robustify playlist table columns initialization
David Fuhrmann
git at videolan.org
Thu Mar 13 19:34:08 CET 2014
vlc/vlc-2.1 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Thu Mar 13 19:06:58 2014 +0100| [ef963d4294287e425b5c9f703e2b092cb3750952] | committer: David Fuhrmann
macosx: robustify playlist table columns initialization
Unknown columns might occur if the prefs are written
by a newer VLC version.
close #10664
(cherry picked from commit 2d39e8f9ab2a2b24bc5703a070feeb94d0f8c4f2)
Signed-off-by: David Fuhrmann <david.fuhrmann at googlemail.com>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=ef963d4294287e425b5c9f703e2b092cb3750952
---
modules/gui/macosx/MainMenu.h | 2 +-
modules/gui/macosx/MainMenu.m | 10 ++++++++--
modules/gui/macosx/playlist.m | 8 +++++++-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/modules/gui/macosx/MainMenu.h b/modules/gui/macosx/MainMenu.h
index e006b6b..7f39773 100644
--- a/modules/gui/macosx/MainMenu.h
+++ b/modules/gui/macosx/MainMenu.h
@@ -246,7 +246,7 @@
- (IBAction)togglePlaymodeButtons:(id)sender;
- (IBAction)toggleSidebar:(id)sender;
- (IBAction)togglePlaylistColumnTable:(id)sender;
-- (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column;
+- (BOOL)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column;
- (NSMenu *)setupPlaylistTableColumnsMenu;
- (IBAction)toggleRecord:(id)sender;
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 17e7481..501016b 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -743,12 +743,18 @@ static VLCMainMenu *_o_sharedInstance = nil;
[[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_new_state translationDict: o_ptc_translation_dict];
}
-- (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
+- (BOOL)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column
{
- NSInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
+ NSUInteger i_tag = [o_ptc_menuorder indexOfObject: o_column];
+ // prevent setting unknown columns
+ if(i_tag == NSNotFound)
+ return NO;
+
[[o_mu_playlistTableColumns itemWithTag: i_tag] setState: i_state];
[[o_mu_playlistTableColumnsContextMenu itemWithTag: i_tag] setState: i_state];
[[[VLCMain sharedInstance] playlist] setColumn: o_column state: i_state translationDict: o_ptc_translation_dict];
+
+ return YES;
}
#pragma mark -
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index a6e21e4..62d913d 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -493,7 +493,9 @@
if ([o_column isEqualToString:@"status"])
continue;
- [o_menu setPlaylistColumnTableState: NSOnState forColumn: o_column];
+ if(![o_menu setPlaylistColumnTableState: NSOnState forColumn: o_column])
+ continue;
+
[[o_outline_view tableColumnWithIdentifier: o_column] setWidth: [[[o_columnArray objectAtIndex:i] objectAtIndex:1] floatValue]];
}
@@ -1352,6 +1354,10 @@
NSTableColumn * o_work_tc;
if (i_state == NSOnState) {
+ NSString *o_title = [o_dict objectForKey:o_column];
+ if (!o_title)
+ return;
+
o_work_tc = [[NSTableColumn alloc] initWithIdentifier: o_column];
[o_work_tc setEditable: NO];
[[o_work_tc dataCell] setFont: [NSFont controlContentFontOfSize:11.]];
More information about the vlc-commits
mailing list