[vlc-commits] commit: skins2: playlist, fix issues when deletion is at stake ( Erwan Tulou )
git at videolan.org
git at videolan.org
Tue Aug 10 11:34:08 CEST 2010
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Aug 10 10:47:37 2010 +0200| [c580a341d85b4bc24481e396897e516060d6fb4a] | committer: Erwan Tulou
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c580a341d85b4bc24481e396897e516060d6fb4a
---
modules/gui/skins2/controls/ctrl_tree.cpp | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp
index dad3e43..a0a438e 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<VarTree, tree_update> &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<VarTree, tree_update> &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<VarTree, tree_update> &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 )
{
More information about the vlc-commits
mailing list