Commit e7a4c97c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: replace playlist_DeleteFromInput() wit playlist_NodeDelete()

playlist_DeleteFromInput() requires recursive search through the whole
playlist to find the correct playlist item. This only makes sense if
the playlist item or playlist item ID are not known.
parent 9d2aa1f9
......@@ -207,7 +207,11 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
return;
// model deletion is done via callback
playlist_DeleteFromInput(p_playlist, [item input], pl_Unlocked);
PL_LOCK;
playlist_item_t *p_root = playlist_ItemGetById(p_playlist, [item plItemId]);
if( p_root != NULL )
playlist_NodeDelete(p_playlist, p_root, false);
PL_UNLOCK;
}];
}
......
......@@ -1341,11 +1341,9 @@ static bool HandlePlaylistKey(intf_thread_t *intf, int key)
playlist_item_t *item;
PL_LOCK;
#warning FIXME
item = sys->plist[sys->box_idx]->item;
if (item->i_children == -1)
playlist_DeleteFromInput(p_playlist, item->p_input, pl_Locked);
else
playlist_NodeDelete(p_playlist, item, false);
playlist_NodeDelete(p_playlist, item, false);
PL_UNLOCK;
vlc_mutex_lock(&sys->pl_lock);
if (sys->box_idx >= sys->box_lines_total - 1)
......
......@@ -757,10 +757,13 @@ void PLModel::doDelete( QModelIndexList selected )
recurseDelete( item->children, &selected );
PL_LOCK;
int i_ret = playlist_DeleteFromInput( p_playlist, item->inputItem(), pl_Locked );
playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
item->id() );
if( p_root != NULL )
playlist_NodeDelete( p_playlist, p_root, false );
PL_UNLOCK;
if( i_ret == VLC_SUCCESS )
if( p_root != NULL )
removeItem( item );
}
}
......
......@@ -59,15 +59,7 @@ void Playtree::delSelected()
playlist_ItemGetById( m_pPlaylist, it->getId() );
if( pItem )
{
if( pItem->i_children == -1 )
{
playlist_DeleteFromInput( m_pPlaylist, pItem->p_input,
pl_Locked );
}
else
{
playlist_NodeDelete( m_pPlaylist, pItem, false );
}
playlist_NodeDelete( m_pPlaylist, pItem, false );
}
playlist_Unlock( m_pPlaylist );
......
......@@ -140,16 +140,14 @@ static int vlclua_playlist_delete( lua_State * L )
{
int i_id = luaL_checkint( L, 1 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
if( !p_item )
{
PL_UNLOCK;
return vlclua_push_ret( L, -1 );
}
int i_ret = playlist_DeleteFromInput( p_playlist, p_item -> p_input, true );
if( p_item != NULL )
playlist_NodeDelete( p_playlist, p_item, false );
PL_UNLOCK;
return vlclua_push_ret( L, i_ret );
return vlclua_push_ret( L, (p_item != NULL) ? 0 : -1 );
}
static int vlclua_playlist_move( lua_State * L )
......
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