[vlc-commits] playlist: replace playlist_DeleteFromInput() wit playlist_NodeDelete()

Rémi Denis-Courmont git at videolan.org
Wed Nov 16 23:05:08 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 16 23:59:09 2016 +0200| [e7a4c97c94c28aad194b8fb9cd292828669e5e4f] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7a4c97c94c28aad194b8fb9cd292828669e5e4f
---

 modules/gui/macosx/VLCPLModel.m                       |  6 +++++-
 modules/gui/ncurses.c                                 |  6 ++----
 modules/gui/qt/components/playlist/playlist_model.cpp |  7 +++++--
 modules/gui/skins2/vars/playtree.cpp                  | 10 +---------
 modules/lua/libs/playlist.c                           | 12 +++++-------
 5 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/modules/gui/macosx/VLCPLModel.m b/modules/gui/macosx/VLCPLModel.m
index f6d64ee..cd7dd4f 100644
--- a/modules/gui/macosx/VLCPLModel.m
+++ b/modules/gui/macosx/VLCPLModel.m
@@ -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;
     }];
 }
 
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index 8206f98..7bfe242 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -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)
diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index 9788699..7e5a991 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -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 );
     }
 }
diff --git a/modules/gui/skins2/vars/playtree.cpp b/modules/gui/skins2/vars/playtree.cpp
index 38357f1..4005ced 100644
--- a/modules/gui/skins2/vars/playtree.cpp
+++ b/modules/gui/skins2/vars/playtree.cpp
@@ -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 );
 
diff --git a/modules/lua/libs/playlist.c b/modules/lua/libs/playlist.c
index 07260a8..771a14a 100644
--- a/modules/lua/libs/playlist.c
+++ b/modules/lua/libs/playlist.c
@@ -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 )



More information about the vlc-commits mailing list