Commit 54e0d270 authored by jpd's avatar jpd
Browse files

SD: remove category node when it becomes empty

parent c8a67b80
......@@ -282,8 +282,25 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_data )
{
input_item_t * p_input = p_event->u.services_discovery_item_removed.p_item;
playlist_item_t * p_parent = user_data;
playlist_DeleteFromInput( p_parent->p_playlist, p_input, false );
playlist_item_t * p_sd_node = user_data;
playlist_t *p_playlist = p_sd_node->p_playlist;
PL_LOCK;
playlist_item_t *p_item =
playlist_ItemFindFromInputAndRoot( p_playlist, p_input,
p_sd_node, false );
if( !p_item )
{
PL_UNLOCK; return;
}
playlist_item_t *p_parent = p_item->p_parent;
/* if the item was added under a category and the category node
becomes empty, delete that node as well */
if( p_parent->i_children > 1 || p_parent == p_sd_node )
playlist_DeleteItem( p_playlist, p_item, true );
else
playlist_NodeDelete( p_playlist, p_parent, true, true );
PL_UNLOCK;
}
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment