]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
playlist.m: Fix the so problematic 21193.
[vlc] / modules / gui / macosx / playlist.m
index aeba4123db44de9b6e763d23d30dbbcd27ed9b5c..beb3842ab694aa0efa08c8de91d06b496bd31236 100644 (file)
     if( [[o_tc identifier] isEqualToString:@"1"] )
     {
         /* sanity check to prevent the NSString class from crashing */
-        if( p_item->p_input->p_meta && p_item->p_input->p_meta->psz_title && 
-            *p_item->p_input->p_meta->psz_title )
+        char *psz_title =  input_item_GetTitle( p_item->p_input );
+        if( !EMPTY_STR( psz_title ) )
         {
-            o_value = [NSString stringWithUTF8String:
-                p_item->p_input->p_meta->psz_title];
+            o_value = [NSString stringWithUTF8String: psz_title];
             if( o_value == NULL )
-                o_value = [NSString stringWithCString:
-                    p_item->p_input->p_meta->psz_title];
+                o_value = [NSString stringWithCString: psz_title];
         } 
-        else if( p_item->p_input->psz_name != NULL )
+        else
         {
-            o_value = [NSString stringWithUTF8String:
-                p_item->p_input->psz_name];
-            if( o_value == NULL )
-                o_value = [NSString stringWithCString:
-                    p_item->p_input->psz_name];
+            char *psz_name = input_item_GetName( p_item->p_input );
+            if( psz_name != NULL )
+            {
+                o_value = [NSString stringWithUTF8String: psz_name];
+                if( o_value == NULL )
+                    o_value = [NSString stringWithCString: psz_name];
+            }
+            free( psz_name );
         }
+        free( psz_title );
     }
-    else if( [[o_tc identifier] isEqualToString:@"2"] && p_item->p_input->p_meta &&
-        p_item->p_input->p_meta->psz_artist && *p_item->p_input->p_meta->psz_artist )
-    {
-        o_value = [NSString stringWithUTF8String:
-            p_item->p_input->p_meta->psz_artist];
-        if( o_value == NULL )
-            o_value = [NSString stringWithCString:
-                p_item->p_input->p_meta->psz_artist];
-    }
-    else if( [[o_tc identifier] isEqualToString:@"3"] )
+    else
     {
-        char psz_duration[MSTRTIME_MAX_SIZE];
-        mtime_t dur = p_item->p_input->i_duration;
-        if( dur != -1 )
+        char *psz_artist = input_item_GetArtist( p_item->p_input );
+        if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
         {
-            secstotimestr( psz_duration, dur/1000000 );
-            o_value = [NSString stringWithUTF8String: psz_duration];
+            o_value = [NSString stringWithUTF8String: psz_artist )];
+            if( o_value == NULL )
+                o_value = [NSString stringWithCString: psz_artist )];
         }
-        else
+        else if( [[o_tc identifier] isEqualToString:@"3"] )
         {
-            o_value = @"-:--:--";
+            char psz_duration[MSTRTIME_MAX_SIZE];
+            mtime_t dur = p_item->p_input->i_duration;
+            if( dur != -1 )
+            {
+                secstotimestr( psz_duration, dur/1000000 );
+                o_value = [NSString stringWithUTF8String: psz_duration];
+            }
+            else
+            {
+                o_value = @"-:--:--";
+            }
         }
+        free( psz_artist );
     }
 
     return( o_value );
     NSMenuItem *o_mi = (NSMenuItem *)sender;
     NSString *o_string = [o_mi representedObject];
     playlist_t * p_playlist = pl_Yield( VLCIntf );
-    if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string cString] ) )
-        playlist_ServicesDiscoveryAdd( p_playlist, [o_string cString] );
+    if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
+        playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
     else
-        playlist_ServicesDiscoveryRemove( p_playlist, [o_string cString] );
+        playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
 
     [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
-                                          [o_string cString] ) ? YES : NO];
+                                          [o_string UTF8String] ) ? YES : NO];
 
     vlc_object_release( p_playlist );
     [self playlistUpdated];