Commit ed22e001 authored by Jakob Leben's avatar Jakob Leben

qt4: prevent moving a node into itself

..or it magically eats itself up
parent 53cd4ad4
...@@ -255,28 +255,35 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -255,28 +255,35 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
} }
else else
{ {
QList<int> ids; QList<playlist_item_t*> items;
while( !stream.atEnd() ) while( !stream.atEnd() )
{ {
int id; int id;
stream >> id; stream >> id;
ids.append(id); playlist_item_t *item = playlist_ItemGetById( p_playlist, id );
} if( !item ) continue;
int count = ids.size(); /* better not try to move a node into itself: */
playlist_item_t *items[count]; if( item->i_children > 0 )
for( int i = 0; i < count; i++ )
{ {
playlist_item_t *item = playlist_ItemGetById( p_playlist, ids[i] ); playlist_item_t *climber = p_parent;
if( !item ) while( climber )
{ {
PL_UNLOCK; if( climber == item ) break;
return false; climber = climber->p_parent;
}
if( climber ) continue;
} }
items[i] = item; items.append( item );
} }
playlist_TreeMoveMany( p_playlist, count, items, p_parent, 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) ); (row == -1 ? p_parent->i_children : row) );
} }
}
PL_UNLOCK; PL_UNLOCK;
/*TODO: That's not a good idea to rebuild the playlist */ /*TODO: That's not a good idea to rebuild the playlist */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment