[vlc-commits] macosx: robustify playlist table columns initialization

David Fuhrmann git at videolan.org
Thu Mar 13 19:32:42 CET 2014


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Thu Mar 13 19:06:58 2014 +0100| [2d39e8f9ab2a2b24bc5703a070feeb94d0f8c4f2] | 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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d39e8f9ab2a2b24bc5703a070feeb94d0f8c4f2
---

 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 36c33db..1fe68e4 100644
--- a/modules/gui/macosx/MainMenu.h
+++ b/modules/gui/macosx/MainMenu.h
@@ -254,7 +254,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)quitAfterPlayback:(id)sender;
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index e774752..baa83d2 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -751,12 +751,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 7c92bb6..5ceba5f 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -522,7 +522,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]];
     }
 
@@ -1392,6 +1394,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