[vlc-devel] commit: Qt4: fix #3113: crash after a playlist item is removed by another plugin (Jakob Leben )

git version control git at videolan.org
Tue Oct 27 22:36:51 CET 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Oct 27 22:04:34 2009 +0100| [0132bb5d2eb90f4878dd4c0b5038bd06b854719e] | committer: Jakob Leben 

Qt4: fix #3113: crash after a playlist item is removed by another plugin

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

 .../gui/qt4/components/playlist/playlist_model.cpp |   18 +++++++++++-------
 .../gui/qt4/components/playlist/playlist_model.hpp |    2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index d07f306..62cbcc5 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -653,9 +653,6 @@ void PLModel::processInputItemUpdate( input_item_t *p_item )
 void PLModel::processItemRemoval( int i_id )
 {
     if( i_id <= 0 ) return;
-    if( i_id == i_cached_id ) i_cached_id = -1;
-    i_cached_input_id = -1;
-
     removeItem( i_id );
 }
 
@@ -760,13 +757,22 @@ void PLModel::removeItem( PLItem *item )
 {
     if( !item ) return;
 
+    if( item->i_id == i_cached_id ) i_cached_id = -1;
+    i_cached_input_id = -1;
+
     if( currentItem == item )
     {
         currentItem = NULL;
         emit currentChanged( QModelIndex() );
     }
 
-    if( item->parentItem ) item->parentItem->removeChild( item );
+    if( item->parentItem ) {
+        int i = item->parentItem->children.indexOf( item );
+        beginRemoveRows( index( item->parentItem, 0), i, i );
+        item->parentItem->children.removeAt(i);
+        delete item;
+        endRemoveRows();
+    }
     else delete item;
 
     if(item == rootItem)
@@ -862,11 +868,9 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
     else
         playlist_NodeDelete( p_playlist, p_item, true, false );
     PL_UNLOCK;
+
     /* And finally, remove it from the tree */
-    int itemIndex = item->parentItem->children.indexOf( item );
-    beginRemoveRows( index( item->parentItem, 0), itemIndex, itemIndex );
     removeItem( item );
-    endRemoveRows();
 }
 
 /******* Volume III: Sorting and searching ********/
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index f48a9ae..10697fb 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -151,12 +151,12 @@ private:
     void recurseDelete( QList<PLItem*> children, QModelIndexList *fullList );
     void doDeleteItem( PLItem *item, QModelIndexList *fullList );
     void updateTreeItem( PLItem * );
+    void removeItem ( PLItem * );
     void takeItem( PLItem * ); //will not delete item
     void insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos );
     void dropAppendCopy( QByteArray& data, PLItem *target );
     void dropMove( QByteArray& data, PLItem *target, int new_pos );
     /* The following actions will not signal the view! */
-    void removeItem ( PLItem * );
     void updateChildren( PLItem * );
     void updateChildren( playlist_item_t *, PLItem * );
 




More information about the vlc-devel mailing list