Commit 705dc653 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: pass playlist item as "playlist-item-deleted" value

This makes deletion and appending somewhat more consistent.
parent 9bd12356
...@@ -106,8 +106,8 @@ struct intf_thread_t; ...@@ -106,8 +106,8 @@ struct intf_thread_t;
* item being played. * item being played.
* *
* - "playlist-item-append": It will contain a pointer to a playlist_item_t. * - "playlist-item-append": It will contain a pointer to a playlist_item_t.
* - "playlist-item-deleted": It will contain the playlist_item_t->i_id of a * - "playlist-item-deleted": It will contain a pointer to the playlist_item_t
* deleted playlist_item_t. * about to be deleted.
* *
* - "leaf-to-parent": It will contain the playlist_item_t->i_id of an item that is transformed * - "leaf-to-parent": It will contain the playlist_item_t->i_id of an item that is transformed
* into a node. * into a node.
......
...@@ -71,7 +71,8 @@ static int VLCPLItemRemoved(vlc_object_t *p_this, const char *psz_var, ...@@ -71,7 +71,8 @@ static int VLCPLItemRemoved(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param) vlc_value_t oldval, vlc_value_t new_val, void *param)
{ {
@autoreleasepool { @autoreleasepool {
NSNumber *o_val = [NSNumber numberWithInt:new_val.i_int]; playlist_item_t *p_item = new_val.p_address;
NSNumber *o_val = [NSNumber numberWithInt:p_item->i_id];
VLCPLModel *model = (__bridge VLCPLModel*)param; VLCPLModel *model = (__bridge VLCPLModel*)param;
[model performSelectorOnMainThread:@selector(VLCPLItemRemoved:) withObject:o_val waitUntilDone:NO]; [model performSelectorOnMainThread:@selector(VLCPLItemRemoved:) withObject:o_val waitUntilDone:NO];
......
...@@ -1248,8 +1248,9 @@ int MainInputManager::PLItemRemoved( vlc_object_t *obj, const char *, ...@@ -1248,8 +1248,9 @@ int MainInputManager::PLItemRemoved( vlc_object_t *obj, const char *,
{ {
playlist_t *pl = (playlist_t *) obj; playlist_t *pl = (playlist_t *) obj;
MainInputManager *mim = static_cast<MainInputManager*>(data); MainInputManager *mim = static_cast<MainInputManager*>(data);
playlist_item_t *item = static_cast<playlist_item_t *>( cur.p_address );
PLEvent *event = new PLEvent( PLEvent::PLItemRemoved, cur.i_int, 0 ); PLEvent *event = new PLEvent( PLEvent::PLItemRemoved, item->i_id, 0 );
QApplication::postEvent( mim, event ); QApplication::postEvent( mim, event );
// can't use playlist_IsEmpty( ) as it isn't true yet // can't use playlist_IsEmpty( ) as it isn't true yet
if ( pl->items.i_size == 1 ) // lock is held if ( pl->items.i_size == 1 ) // lock is held
......
...@@ -282,9 +282,9 @@ int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable, ...@@ -282,9 +282,9 @@ int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
(void)pObj; (void)pVariable; (void)oldVal; (void)pObj; (void)pVariable; (void)oldVal;
VlcProc *pThis = (VlcProc*)pParam; VlcProc *pThis = (VlcProc*)pParam;
int i_id = newVal.i_int; playlist_item_t *item = static_cast<playlist_item_t *>(newVal.p_address);
CmdPlaytreeDelete *pCmdTree = CmdPlaytreeDelete *pCmdTree =
new CmdPlaytreeDelete( pThis->getIntf(), i_id); new CmdPlaytreeDelete( pThis->getIntf(), item->i_id);
// Push the command in the asynchronous command queue // Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() ); AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
......
...@@ -420,10 +420,8 @@ static void VariablesInit( playlist_t *p_playlist ) ...@@ -420,10 +420,8 @@ static void VariablesInit( playlist_t *p_playlist )
var_Create( p_playlist, "item-change", VLC_VAR_ADDRESS ); var_Create( p_playlist, "item-change", VLC_VAR_ADDRESS );
var_Create( p_playlist, "leaf-to-parent", VLC_VAR_INTEGER ); var_Create( p_playlist, "leaf-to-parent", VLC_VAR_INTEGER );
var_Create( p_playlist, "playlist-item-deleted", VLC_VAR_INTEGER );
var_SetInteger( p_playlist, "playlist-item-deleted", -1 );
var_Create( p_playlist, "playlist-item-append", VLC_VAR_ADDRESS ); var_Create( p_playlist, "playlist-item-append", VLC_VAR_ADDRESS );
var_Create( p_playlist, "playlist-item-deleted", VLC_VAR_ADDRESS );
var_Create( p_playlist, "input-current", VLC_VAR_ADDRESS ); var_Create( p_playlist, "input-current", VLC_VAR_ADDRESS );
......
...@@ -148,7 +148,7 @@ void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -148,7 +148,7 @@ void playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
int i; int i;
var_SetInteger( p_playlist, "playlist-item-deleted", p_root->i_id ); var_SetAddress( p_playlist, "playlist-item-deleted", p_root );
ARRAY_BSEARCH( pl_priv(p_playlist)->all_items, ->i_id, int, p_root->i_id, i ); ARRAY_BSEARCH( pl_priv(p_playlist)->all_items, ->i_id, int, p_root->i_id, i );
if( i != -1 ) if( i != -1 )
ARRAY_REMOVE( pl_priv(p_playlist)->all_items, i ); ARRAY_REMOVE( pl_priv(p_playlist)->all_items, i );
......
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