[vlc-devel] commit: Qt4: fix segfault when exiting after a service discovery has been activated ( Jakob Leben )

git version control git at videolan.org
Mon Sep 14 01:27:56 CEST 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Mon Sep 14 01:26:20 2009 +0200| [652114837848f6557ceca76032dedff3ebdc561a] | committer: Jakob Leben 

Qt4: fix segfault when exiting after a service discovery has been activated

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

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

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index e271e2d..fdb9f41 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -526,6 +526,7 @@ PLItem *PLModel::findByInput( PLItem *root, int i_id )
 
 PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_input )
 {
+    if( !root ) return NULL;
     if( ( !b_input && i_cached_id == i_id) ||
         ( b_input && i_cached_input_id ==i_id ) )
     {
@@ -755,14 +756,21 @@ void PLModel::insertChildren( PLItem *node, QList<PLItem*>& items, int i_pos )
 void PLModel::removeItem( PLItem *item )
 {
     if( !item ) return;
+
     if( currentItem == item )
     {
         currentItem = NULL;
         emit currentChanged( QModelIndex() );
     }
-    PLItem *parent = item->parentItem;
-    assert( parent );
-    parent->removeChild( item );
+
+    if( item->parentItem ) item->parentItem->removeChild( item );
+    else delete item;
+
+    if(item == rootItem)
+    {
+        rootItem = NULL;
+        reset();
+    }
 }
 
 /* This function must be entered WITH the playlist lock */




More information about the vlc-devel mailing list