From: Erwan Tulou Date: Tue, 10 Aug 2010 08:47:37 +0000 (+0200) Subject: skins2: playlist, fix issues when deletion is at stake X-Git-Tag: 1.2.0-pre1~5489 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c580a341d85b4bc24481e396897e516060d6fb4a;p=vlc skins2: playlist, fix issues when deletion is at stake This patch does the following - do not reset m_firstPosition when not needed - fix corner case when playlist is flat (prone to crash) The node with a single leaf being deleted should become the next leaf. But, actually just forcing the rtree.begin() in any case is simpler and no problem here. --- diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp index dad3e43aaf..a0a438ea58 100644 --- a/modules/gui/skins2/controls/ctrl_tree.cpp +++ b/modules/gui/skins2/controls/ctrl_tree.cpp @@ -138,8 +138,6 @@ int CtrlTree::maxItems() void CtrlTree::onUpdate( Subject &rTree, tree_update *arg ) { - m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin(); - if( arg->i_type == 0 ) // Item update { if( arg->b_active_item ) @@ -152,6 +150,8 @@ void CtrlTree::onUpdate( Subject &rTree, /// \todo handle delete in a more clever way else if ( arg->i_type == 1 ) // Global change or deletion { + m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin(); + makeImage(); } else if ( arg->i_type == 2 ) // Item-append @@ -168,14 +168,15 @@ void CtrlTree::onUpdate( Subject &rTree, else if( arg->i_type == 3 ) // item-del { /* Make sure firstPos and lastSelected are still valid */ - while( m_firstPos->m_deleted && m_firstPos != m_rTree.root()->begin() ) + while( m_firstPos->m_deleted && + m_firstPos != (m_flat ? m_rTree.firstLeaf() + : m_rTree.begin()) ) { m_firstPos = m_flat ? m_rTree.getPrevLeaf( m_firstPos ) : m_rTree.getPrevVisibleItem( m_firstPos ); } if( m_firstPos->m_deleted ) - m_firstPos = m_flat ? m_rTree.firstLeaf() - : m_rTree.root()->begin(); + m_firstPos = m_rTree.begin(); if( arg->b_visible == true ) {