]> git.sesse.net Git - vlc/commitdiff
skins2: playlist a few iterator issues
authorErwan Tulou <erwan10@videolan.org>
Mon, 9 Aug 2010 20:41:30 +0000 (22:41 +0200)
committerErwan Tulou <erwan10@videolan.org>
Tue, 10 Aug 2010 09:30:50 +0000 (11:30 +0200)
- check validity before using iterators
- don't use iterator anymore once the item is erased

modules/gui/skins2/vars/playtree.cpp

index 05cb89fb7a5166347ccc436b95d66e30540d4fb2..73008fc1be1f5d5e37c748a4c94a74a9f81ef0c2 100644 (file)
@@ -149,7 +149,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
@@ -164,7 +165,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 );
@@ -187,9 +189,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 );
     }
 }