Remove playlist items when destroying the playlist...
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 10 Jan 2009 17:42:48 +0000 (19:42 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 10 Jan 2009 17:42:48 +0000 (19:42 +0200)
...rather than when disabling it. Otherwise service discovery plugins
cannot possibly cleanup after themselves (and CABOOM).

src/playlist/engine.c
src/playlist/thread.c

index e1e9e11..b6f82ed 100644 (file)
@@ -181,6 +181,24 @@ static void playlist_Destructor( vlc_object_t * p_this )
     assert( !p_sys->p_fetcher );
 
     vlc_cond_destroy( &p_sys->signal );
+
+    /* Remove all remaining items */
+    FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
+        free( p_del->pp_children );
+        vlc_gc_decref( p_del->p_input );
+        free( p_del );
+    FOREACH_END();
+    ARRAY_RESET( p_playlist->all_items );
+    FOREACH_ARRAY( playlist_item_t *p_del, p_sys->items_to_delete )
+        free( p_del->pp_children );
+        vlc_gc_decref( p_del->p_input );
+        free( p_del );
+    FOREACH_END();
+    ARRAY_RESET( p_sys->items_to_delete );
+
+    ARRAY_RESET( p_playlist->items );
+    ARRAY_RESET( p_playlist->current );
+
     msg_Dbg( p_this, "Destroyed" );
 }
 
index 1d1a724..b2ad676 100644 (file)
@@ -118,22 +118,6 @@ void playlist_Deactivate( playlist_t *p_playlist )
     /* Release the current item */
     set_current_status_item( p_playlist, NULL );
 
-    FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
-        free( p_del->pp_children );
-        vlc_gc_decref( p_del->p_input );
-        free( p_del );
-    FOREACH_END();
-    ARRAY_RESET( p_playlist->all_items );
-    FOREACH_ARRAY( playlist_item_t *p_del, p_sys->items_to_delete )
-        free( p_del->pp_children );
-        vlc_gc_decref( p_del->p_input );
-        free( p_del );
-    FOREACH_END();
-    ARRAY_RESET( p_sys->items_to_delete );
-
-    ARRAY_RESET( p_playlist->items );
-    ARRAY_RESET( p_playlist->current );
-
     PL_UNLOCK;
 
     msg_Dbg( p_playlist, "Deactivated" );