[vlc-commits] commit: skins2: playlist a few iterator issues (Erwan Tulou )

git at videolan.org git at videolan.org
Thu Aug 12 08:32:00 CEST 2010


vlc/vlc-1.1 | branch: master | Erwan Tulou <erwan10 at videolan.org> | Mon Aug  9 22:41:30 2010 +0200| [7659cde94d124b875f1e0e31c071e8fbc33e0a12] | committer: Erwan Tulou 

skins2: playlist a few iterator issues

- check validity before using iterators
- don't use iterator anymore once the item is erased
(cherry picked from commit 81652244c4049260892d4def1011c82cd3e303cb)

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

 modules/gui/skins2/vars/playtree.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/modules/gui/skins2/vars/playtree.cpp b/modules/gui/skins2/vars/playtree.cpp
index 2407e38..515d6f5 100644
--- a/modules/gui/skins2/vars/playtree.cpp
+++ b/modules/gui/skins2/vars/playtree.cpp
@@ -152,7 +152,8 @@ void Playtree::onUpdateCurrent( bool b_active )
             return;
 
         Iterator it = findById( m_currentItem->i_id );
-        it->m_playing = false;
+        if( it != end() )
+            it->m_playing = false;
         m_currentItem = NULL;
     }
     else
@@ -167,7 +168,8 @@ void Playtree::onUpdateCurrent( bool b_active )
         }
 
         Iterator it = findById( current->i_id );
-        it->m_playing = true;
+        if( it != end() )
+            it->m_playing = true;
         m_currentItem = current;
 
         playlist_Unlock( m_pPlaylist );
@@ -190,9 +192,11 @@ void Playtree::onDelete( int i_id )
     Iterator item = findById( i_id ) ;
     if( item != end() )
     {
-        if( item->parent() )
-            item->parent()->removeChild( item );
-        descr.b_visible = item->parent() ? item->parent()->m_expanded : true;
+        VarTree* parent = item->parent();
+        if( parent )
+            parent->removeChild( item );
+
+        descr.b_visible = parent ? parent->m_expanded : true;
         notify( &descr );
     }
 }



More information about the vlc-commits mailing list