[vlc-devel] commit: qt4: prevent moving a node into itself (Jakob Leben )
git version control
git at videolan.org
Wed Aug 19 14:39:37 CEST 2009
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Aug 19 14:38:29 2009 +0200| [ed22e00185e0fe2471dbdf0dd4fce801d2ddb10a] | committer: Jakob Leben
qt4: prevent moving a node into itself
..or it magically eats itself up
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ed22e00185e0fe2471dbdf0dd4fce801d2ddb10a
---
.../gui/qt4/components/playlist/playlist_model.cpp | 35 ++++++++++++--------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 30f4c60..24462b2 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -255,27 +255,34 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
}
else
{
- QList<int> ids;
+ QList<playlist_item_t*> items;
while( !stream.atEnd() )
{
int id;
stream >> id;
- ids.append(id);
- }
- int count = ids.size();
- playlist_item_t *items[count];
- for( int i = 0; i < count; i++ )
- {
- playlist_item_t *item = playlist_ItemGetById( p_playlist, ids[i] );
- if( !item )
+ playlist_item_t *item = playlist_ItemGetById( p_playlist, id );
+ if( !item ) continue;
+ /* better not try to move a node into itself: */
+ if( item->i_children > 0 )
{
- PL_UNLOCK;
- return false;
+ playlist_item_t *climber = p_parent;
+ while( climber )
+ {
+ if( climber == item ) break;
+ climber = climber->p_parent;
+ }
+ if( climber ) continue;
}
- items[i] = item;
+ items.append( item );
+ }
+ int count = items.size();
+ if( count )
+ {
+ playlist_item_t *pp_items[count];
+ for( int i = 0; i < count; i++ ) pp_items[i] = items[i];
+ playlist_TreeMoveMany( p_playlist, count, pp_items, p_parent,
+ (row == -1 ? p_parent->i_children : row) );
}
- playlist_TreeMoveMany( p_playlist, count, items, p_parent,
- (row == -1 ? p_parent->i_children : row) );
}
PL_UNLOCK;
More information about the vlc-devel
mailing list