]> git.sesse.net Git - vlc/blobdiff - src/playlist/item.c
Fix previous commit ;.
[vlc] / src / playlist / item.c
index cceb5f5e8c8ef50db1484b9490584a7dd2b05bf7..8ec3924660a22e4a5de8fe4e3131cbab7faeabc2 100644 (file)
@@ -54,8 +54,8 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
     b_play = var_CreateGetBool( p_playlist, "playlist-autostart" );
 
     /* This part is really hakish, but this playlist system isn't simple */
-    /* First check if we haven't already added the item as we are 
-     * listening using the onelevel and the category representent 
+    /* First check if we haven't already added the item as we are
+     * listening using the onelevel and the category representent
      * (Because of the playlist design) */
     p_child_in_category = playlist_ItemFindFromInputAndRoot(
                             p_playlist, p_child->i_id,
@@ -83,9 +83,10 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
         {
             p_item_in_category = playlist_ItemToNode( p_playlist,
                     p_item_in_category, VLC_TRUE );
+            p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST;
         }
-        
-        playlist_BothAddInput( p_playlist, p_child, p_item_in_category, 
+        playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
                 PLAYLIST_APPEND | PLAYLIST_SPREPARSE , PLAYLIST_END,
                 NULL, NULL,  VLC_TRUE );
 
@@ -95,7 +96,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
                           VLC_TRUE, p_item_in_category, NULL );
         }
     }
-    
     PL_UNLOCK;
 
 }
@@ -117,7 +118,7 @@ static void uninstall_input_item_observer( playlist_item_t * p_item,
     vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                       input_item_subitem_added,
                       p_item );
-                      
 }
 
 /*****************************************************************************
@@ -229,8 +230,8 @@ int playlist_DeleteFromInput( playlist_t *p_playlist, int i_input_id,
 void playlist_Clear( playlist_t * p_playlist, vlc_bool_t b_locked )
 {
     if( !b_locked ) PL_LOCK;
-    playlist_NodeEmpty( p_playlist, p_playlist->p_root_category, VLC_TRUE );
-    playlist_NodeEmpty( p_playlist, p_playlist->p_root_onelevel, VLC_TRUE );
+    playlist_NodeEmpty( p_playlist, p_playlist->p_local_category, VLC_TRUE );
+    playlist_NodeEmpty( p_playlist, p_playlist->p_local_onelevel, VLC_TRUE );
     if( !b_locked ) PL_UNLOCK;
 }
 
@@ -294,9 +295,11 @@ int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
 
     i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
                                b_locked );
-    if( i_ret == VLC_SUCCESS )
-        return p_input->i_id;
-    return -1;
+    int i_id = i_ret == VLC_SUCCESS ? p_input->i_id : -1;
+
+    vlc_gc_decref( p_input );
+
+    return i_id;
 }
 
 /** Add an input item to the playlist node */