]> git.sesse.net Git - vlc/commitdiff
Qt: kill a bug in playlist model
authorJakob Leben <jleben@videolan.org>
Tue, 2 Feb 2010 06:17:54 +0000 (07:17 +0100)
committerJakob Leben <jleben@videolan.org>
Tue, 2 Feb 2010 06:17:54 +0000 (07:17 +0100)
modules/gui/qt4/components/playlist/playlist_model.cpp

index da0fccf3fe326a41d6ec39a1a24d0c8d50302fa8..2c3b8d22babd79db0594c46313456d38789147e8 100644 (file)
@@ -609,6 +609,7 @@ void PLModel::processItemAppend( int i_item, int i_parent )
     playlist_item_t *p_item = NULL;
     PLItem *newItem = NULL;
     input_thread_t *currentInputThread;
+    int pos;
 
     PLItem *nodeItem = findById( rootItem, i_parent );
     if( !nodeItem ) return;
@@ -620,6 +621,9 @@ void PLModel::processItemAppend( int i_item, int i_parent )
     p_item = playlist_ItemGetById( p_playlist, i_item );
     if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
 
+    for( pos = 0; pos < p_item->p_parent->i_children; pos++ )
+        if( p_item->p_parent->pp_children[pos] == p_item ) break;
+
     newItem = new PLItem( p_item, nodeItem );
     PL_UNLOCK;
 
@@ -628,8 +632,8 @@ void PLModel::processItemAppend( int i_item, int i_parent )
         newItem->p_input == input_GetItem( currentInputThread ) )
             currentItem = newItem;
 
-    beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() );
-    nodeItem->appendChild( newItem );
+    beginInsertRows( index( nodeItem, 0 ), pos, pos );
+    nodeItem->insertChild( newItem, pos );
     endInsertRows();
 
     if( currentItem == newItem )