[vlc-devel] commit: playlist: do not move both tree and non-tree items + restrict move action ( Jakob Leben )

git version control git at videolan.org
Thu Aug 13 17:04:44 CEST 2009


vlc | branch: master | Jakob Leben <jakob.leben at gmail.com> | Mon Aug 10 00:04:59 2009 +0200| [a2d9bd0a079e288e89224e39ae85e3b7c3923963] | committer: Rémi Denis-Courmont 

playlist: do not move both tree and non-tree items + restrict move action

Items are stored twice, once in a tree structure and once in a one-level list.
This patch removes attempt of the playlist_TreeMove() function to move both tree and
one-level instances of an item.

Firstly the reason is that function was not effective in this attempt.
And secondly, the attempt itself doesn't make sense in some cases: you can always
map moves within the tree to moves within one-level, but you can't always do it
the other way around, it is in most cases ambiguous.

Moreover, this patch restricts moves in the tree to within the present parent of the
item being moved. Again, in most cases, moving an item out of its parent or into another
parent is meaningless.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 src/playlist/item.c |   43 ++-----------------------------------------
 1 files changed, 2 insertions(+), 41 deletions(-)

diff --git a/src/playlist/item.c b/src/playlist/item.c
index 23cff64..4051a82 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -718,47 +718,8 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
     int i_ret;
     PL_ASSERT_LOCKED;
 
-    /* Drop on a top level node. Move in the two trees */
-    if( p_node->p_parent == p_playlist->p_root_category ||
-        p_node->p_parent == p_playlist->p_root_onelevel )
-    {
-        /* Fixme: avoid useless lookups but we need some clean helpers */
-        {
-            /* Fixme: if we try to move a node on a top-level node, it will
-             * fail because the node doesn't exist in onelevel and we will
-             * do some shit in onelevel. We should recursively move all items
-             * within the node */
-            playlist_item_t *p_node_onelevel;
-            playlist_item_t *p_item_onelevel;
-            p_node_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_node->p_input,
-                                                p_playlist->p_root_onelevel,
-                                                false );
-            p_item_onelevel = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_item->p_input,
-                                                p_playlist->p_root_onelevel,
-                                                false );
-            if( p_node_onelevel && p_item_onelevel )
-                TreeMove( p_playlist, p_item_onelevel, p_node_onelevel, i_newpos );
-        }
-        {
-            playlist_item_t *p_node_category;
-            playlist_item_t *p_item_category;
-            p_node_category = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_node->p_input,
-                                                p_playlist->p_root_category,
-                                                false );
-            p_item_category = playlist_ItemFindFromInputAndRoot( p_playlist,
-                                                p_item->p_input,
-                                                p_playlist->p_root_category,
-                                                false );
-            if( p_node_category && p_item_category )
-                TreeMove( p_playlist, p_item_category, p_node_category, 0 );
-        }
-        i_ret = VLC_SUCCESS;
-    }
-    else
-        i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
+    if( p_node != p_item->p_parent ) return VLC_SUCCESS;
+    i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
     pl_priv(p_playlist)->b_reset_currently_playing = true;
     vlc_cond_signal( &pl_priv(p_playlist)->signal );
     return i_ret;




More information about the vlc-devel mailing list