]> git.sesse.net Git - vlc/blobdiff - src/playlist/engine.c
More clean up (it has 1 minor side effect but in a buggy section anyway).
[vlc] / src / playlist / engine.c
index f6385d01e3a83f63e0d750f3f1ef4270aa39b50a..bb0f2e4c23637186a467d7d08893fd0300d8402a 100644 (file)
@@ -169,10 +169,19 @@ static void playlist_Destructor( vlc_object_t * p_this )
     playlist_t * p_playlist = (playlist_t *)p_this;
 
     if( p_playlist->p_preparse )
+    {
+        vlc_object_kill( p_playlist->p_preparse );
+        vlc_thread_join( p_playlist->p_preparse );
         vlc_object_release( p_playlist->p_preparse );
+    }
 
     if( p_playlist->p_fetcher )
+    {
+        vlc_object_kill( p_playlist->p_fetcher );
+        vlc_thread_join( p_playlist->p_fetcher );
         vlc_object_release( p_playlist->p_fetcher );
+    }
+    msg_Dbg( p_this, "Destroyed" );
 }
 
 /* Destroy remaining objects */
@@ -477,6 +486,23 @@ void playlist_LastLoop( playlist_t *p_playlist )
         sout_DeleteInstance( p_sout );
 #endif
 
+    if( p_playlist->status.p_node &&
+        p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG )
+    {
+         PL_DEBUG( "%s was marked for deletion, deleting",
+                         PLI_NAME( p_playlist->status.p_node  ) );
+         playlist_ItemDelete( p_playlist->status.p_node );
+         p_playlist->status.p_node = NULL;
+    }
+    if( p_playlist->status.p_item &&
+        p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG )
+    {
+         PL_DEBUG( "%s was marked for deletion, deleting",
+                         PLI_NAME( p_playlist->status.p_item  ) );
+         playlist_ItemDelete( p_playlist->status.p_item );
+         p_playlist->status.p_item = NULL;
+    }
+
     /* Core should have terminated all SDs before the playlist */
     /* TODO: It fails to do so when not playing anything -- Courmisch */
     playlist_ServicesDiscoveryKillAll( p_playlist );
@@ -582,6 +608,13 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }
 
@@ -663,6 +696,13 @@ void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
         msleep( (i_activity+1) * 1000 );
         vlc_object_lock( p_obj );
     }
+
+    for( int i = 0; i < p_obj->i_waiting; i++ )
+    {
+        vlc_gc_decref( p_obj->pp_waiting[i] );
+        REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+    }
+
     vlc_object_unlock( p_obj );
 }