Commit 953d13ba authored by Jakob Leben's avatar Jakob Leben Committed by Rémi Denis-Courmont

Qt4 playlist: take 2: fix segfault and other enhancements

Fix segfault when dropping more then one item onto an item in the left side selector.

Also copy instead of move items when dragging from media library to playlist and the opposite.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 9ffe4106
...@@ -210,6 +210,12 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -210,6 +210,12 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
return false; return false;
} }
bool copy = false;
if( row == -1 &&
( p_parent->p_input == p_playlist->p_local_category->p_input
|| p_parent->p_input == p_playlist->p_ml_category->p_input ) )
copy = true;
QByteArray encodedData = data->data( "vlc/playlist-item-id" ); QByteArray encodedData = data->data( "vlc/playlist-item-id" );
QDataStream stream( &encodedData, QIODevice::ReadOnly ); QDataStream stream( &encodedData, QIODevice::ReadOnly );
...@@ -228,22 +234,27 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -228,22 +234,27 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
PL_UNLOCK; PL_UNLOCK;
return false; return false;
} }
if( copy )
{
input_item_t *input = p_src->p_input;
playlist_AddExt ( p_playlist,
p_src->p_input->psz_uri, p_src->p_input->psz_name,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
input->i_duration,
input->i_options, input->ppsz_options, input->optflagc,
p_parent == p_playlist->p_local_category, true );
continue;
}
if( !p_target ) if( !p_target )
{ {
if(row == -1) if ( row == -1 ) row = p_parent->i_children;
{ playlist_TreeMove( p_playlist, p_src, p_parent, row );
playlist_TreeMove( p_playlist, p_src, p_parent, 0 );
}
else {
playlist_TreeMove( p_playlist, p_src, p_parent, row );
}
} }
else else
{ {
int i; for( row = 0 ; row < p_target->p_parent->i_children ; row++ )
for( i = 0 ; i< p_parent->i_children ; i++ ) if( p_target->p_parent->pp_children[row] == p_target ) break;
if( p_parent->pp_children[i] == p_target ) break; playlist_TreeMove( p_playlist, p_src, p_parent, row + 1 );
playlist_TreeMove( p_playlist, p_src, p_parent, i + 1 );
} }
p_target = p_src; p_target = p_src;
} }
......
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