[vlc-devel] commit: Qt4 playlist: take 2: fix segfault and other enhancements ( 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> | Wed Aug 12 14:19:49 2009 +0200| [953d13ba71b1e2df067e3f10b48b3f456fedcc13] | committer: Rémi Denis-Courmont 

Qt4 playlist: take 2: fix segfault and other enhancements

Fix segfault when dropping more then one item onto an item in the left side selector.

Also copy instead of move items when dragging from media library to playlist and the opposite.

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

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

 .../gui/qt4/components/playlist/playlist_model.cpp |   33 +++++++++++++------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index d60c078..4a0ecd4 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -210,6 +210,12 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
             return false;
         }
 
+        bool copy = false;
+        if( row == -1 &&
+            ( p_parent->p_input == p_playlist->p_local_category->p_input
+            || p_parent->p_input == p_playlist->p_ml_category->p_input ) )
+                copy = true;
+
         QByteArray encodedData = data->data( "vlc/playlist-item-id" );
         QDataStream stream( &encodedData, QIODevice::ReadOnly );
 
@@ -228,22 +234,27 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
                 PL_UNLOCK;
                 return false;
             }
+            if( copy )
+            {
+                input_item_t *input = p_src->p_input;
+                playlist_AddExt ( p_playlist,
+                    p_src->p_input->psz_uri, p_src->p_input->psz_name,
+                    PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
+                    input->i_duration,
+                    input->i_options, input->ppsz_options, input->optflagc,
+                    p_parent == p_playlist->p_local_category, true );
+                continue;
+            }
             if( !p_target )
             {
-                if(row == -1)
-                {
-                    playlist_TreeMove( p_playlist, p_src, p_parent, 0 );
-                }
-                else {
-                    playlist_TreeMove( p_playlist, p_src, p_parent, row );
-                }
+                if ( row == -1 ) row = p_parent->i_children;
+                playlist_TreeMove( p_playlist, p_src, p_parent, row );
             }
             else
             {
-                int i;
-                for( i = 0 ; i< p_parent->i_children ; i++ )
-                    if( p_parent->pp_children[i] == p_target ) break;
-                playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
+                for( row = 0 ; row < p_target->p_parent->i_children ; row++ )
+                    if( p_target->p_parent->pp_children[row] == p_target ) break;
+                playlist_TreeMove( p_playlist, p_src, p_parent, row + 1 );
             }
             p_target = p_src;
         }




More information about the vlc-devel mailing list