]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
macosx: Don't try to guess a name anymore. This is now done in the core.
[vlc] / modules / gui / macosx / playlist.m
index e80c9b33bc8124b5543e09cd9497580958a9eba9..7ccffecb1550be403b28f64995473122f05aa61e 100644 (file)
     int i_return = 0;
     playlist_t *p_playlist = pl_Hold( VLCIntf );
 
+    PL_LOCK;
     if( item == nil )
     {
         /* root object */
         if( p_item )
             i_return = p_item->i_children;
     }
+    PL_UNLOCK;
     pl_Release( VLCIntf );
 
     return (i_return >= 0);
         /* update the state of our Reveal-in-Finder menu items */
         NSMutableString *o_mrl;
         char *psz_uri = input_item_GetURI( p_item->p_input );
+
+        [o_mi_revealInFinder setEnabled: NO];
+        [o_mm_mi_revealInFinder setEnabled: NO];
         if( psz_uri )
         {
             o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
             {
                 [o_mi_revealInFinder setEnabled: YES];
                 [o_mm_mi_revealInFinder setEnabled: YES];
-                return;
             }
+            free( psz_uri );
         }
-        [o_mi_revealInFinder setEnabled: NO];
-        [o_mm_mi_revealInFinder setEnabled: NO];
 
         if( [[VLCMain sharedInstance] isPlaylistCollapsed] == NO )
         {
         [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
         p_temp_item = p_temp_item->p_parent;
     }
+    PL_UNLOCK;
 
     for( j = 0; j < [o_array count] - 1; j++ )
     {
         {
             [o_outline_view expandItem: o_item];
         }
-
     }
 
-    PL_UNLOCK;
     pl_Release( VLCIntf );
 }
 
 
     p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
 
+    PL_LOCK;
     if( p_item )
     {
         if( p_item->i_children == -1 )
         {
             p_node = p_item->p_parent;
-
         }
         else
         {
                 p_item = NULL;
             }
         }
-        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Unlocked, p_node, p_item );
+        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item );
     }
+    PL_UNLOCK;
     pl_Release( p_intf );
 }
 
 
     p_playlist = pl_Hold( p_intf );
 
-    PL_LOCK;
     for( int i = 0; i < i_count; i++ )
     {
         o_number = [o_to_delete lastObject];
         i_row = [o_number intValue];
         id o_item = [o_outline_view itemAtRow: i_row];
+        [o_outline_view deselectRow: i_row];
+
+        PL_LOCK;
         playlist_item_t *p_item = [o_item pointerValue];
 #ifndef NDEBUG
         msg_Dbg( p_intf, "deleting item %i (of %i) with id \"%i\", pointerValue \"%p\" and %i children", i+1, i_count, 
                 p_item->p_input->i_id, [o_item pointerValue], p_item->i_children +1 );
 #endif
         [o_to_delete removeObject: o_number];
-        [o_outline_view deselectRow: i_row];
 
         if( p_item->i_children != -1 )
         //is a node and not an item
         }
         else
             playlist_DeleteFromInput( p_playlist, p_item->p_input, pl_Locked );
+
+        PL_UNLOCK;
+        [o_outline_dict removeObjectForKey:[NSString stringWithFormat:@"%p",
+                                                     [o_item pointerValue]]];
+        [o_item release];
     }
-    PL_UNLOCK;
 
     [self playlistUpdated];
     pl_Release( p_intf );
         p_item = p_playlist->p_root_category;
     }
 
+    PL_LOCK;
     if( p_item->i_children > -1 ) // the item is a node
     {
-        PL_LOCK;
         playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
-        PL_UNLOCK;
     }
     else
     {
-        PL_LOCK;
         playlist_RecursiveNodeSort( p_playlist,
                 p_item->p_parent, i_mode, ORDER_NORMAL );
-        PL_UNLOCK;
     }
+    PL_UNLOCK;
     pl_Release( VLCIntf );
     [self playlistUpdated];
 }
             }
         }
     }
-    /* If no name, then make a guess */
-    if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
 
     if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
         [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
         o_uri = o_temp;
     }
 
-    p_input = input_item_New( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
+    p_input = input_item_New( p_playlist, [o_uri fileSystemRepresentation], o_name ? [o_name UTF8String] : NULL );
     if( !p_input )
     {
         pl_Release( p_intf );
     {
         for( i = 0; i < (int)[o_options count]; i++ )
         {
-            input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ),
+            input_item_AddOption( p_input, [[o_options objectAtIndex:i] UTF8String],
                                   VLC_INPUT_OPTION_TRUSTED );
         }
     }
     }
     if( i_row > -1 )
     {
-        [o_outline_view selectRow:i_row byExtendingSelection: NO];
+               [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
         [o_outline_view scrollRowToVisible: i_row];
     }
     pl_Release( VLCIntf );
         }
 
         [o_outline_view deselectAll: self];
-        [o_outline_view selectRow: i_row byExtendingSelection: NO];
+        [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
         [o_outline_view scrollRowToVisible: i_row];
 
         pl_Release( VLCIntf );