Commit c3550b59 authored by Clément Stenac's avatar Clément Stenac

Better fix for wx deadlock with preparse

A few fixes
parent b20da1c5
......@@ -290,7 +290,6 @@ VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, cons
VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
/* Tree walking */
playlist_item_t *playlist_FindNextFromParent( playlist_t *p_playlist,
int i_view,
......@@ -395,6 +394,8 @@ static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
return( b_empty );
}
/**
* @}
*/
......@@ -401,7 +401,7 @@ static int ReadDir( playlist_t *p_playlist,
/* Change the item to a node */
if( p_parent->i_children == -1 )
{
playlist_ItemToNode( p_playlist,p_parent );
playlist_LockItemToNode( p_playlist,p_parent );
}
/* get the first directory entry */
......
......@@ -60,7 +60,6 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
static int ItemDeleted( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t oval, vlc_value_t nval, void *param );
/*****************************************************************************
* Event Table.
*****************************************************************************/
......@@ -405,6 +404,7 @@ Playlist::~Playlist()
var_DelCallback( p_playlist, "item-change", ItemChanged, this );
var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
var_DelCallback( p_playlist, "item-append", ItemAppended, this );
var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
vlc_object_release( p_playlist );
}
......@@ -1476,13 +1476,17 @@ void Playlist::OnPopupPreparse( wxMenuEvent& event )
{
return;
}
Preparse( p_playlist );
vlc_object_release( p_playlist );
}
void Playlist::Preparse( playlist_t *p_playlist )
{
if( p_popup_item != NULL )
{
if( p_popup_item->i_children == -1 )
{
wxMutexGuiLeave();
playlist_PreparseEnqueue( p_playlist, &p_popup_item->input );
wxMutexGuiEnter();
}
else
{
......@@ -1494,11 +1498,10 @@ void Playlist::OnPopupPreparse( wxMenuEvent& event )
i_popup_item = FindItem( treectrl->GetRootItem(),
p_parent->pp_children[i] );
p_popup_item = p_parent->pp_children[i];
OnPopupPreparse( dummy );
Preparse( p_playlist );
}
}
}
vlc_object_release( p_playlist );
}
void Playlist::OnPopupDel( wxMenuEvent& event )
......
......@@ -855,6 +855,8 @@ private:
void OnPopupInfo( wxMenuEvent& event );
void Rebuild();
void Preparse( playlist_t *p_playlist );
/* Update */
void UpdateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
void UpdateNodeChildren( playlist_t *, playlist_item_t*, wxTreeItemId );
......
......@@ -304,6 +304,7 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
/* Create Object Variables for private use only */
input_ConfigVarInit( p_input );
input_ControlVarInit( p_input );
p_input->input.i_cr_average = var_GetInteger( p_input, "cr-average" );
......
......@@ -622,6 +622,11 @@ int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem,
* \return returns VLC_SUCCESS or an error
*/
int playlist_Delete( playlist_t * p_playlist, int i_id )
{
return playlist_DeleteInternal( p_playlist, i_id );
}
int playlist_DeleteInternal( playlist_t * p_playlist, int i_id,
vlc_bool_t b_force )
{
vlc_value_t val;
int i;
......
......@@ -701,10 +701,13 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
if( p_obj->i_waiting > 0 )
{
input_Preparse( p_playlist, p_obj->pp_waiting[0] );
var_SetInteger( p_playlist, "item-change",
p_obj->pp_waiting[0]->i_id );
input_item_t *p_current = p_obj->pp_waiting[0];
REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
input_Preparse( p_playlist, p_current );
var_SetInteger( p_playlist, "item-change", p_current->i_id );
vlc_mutex_lock( &p_obj->object_lock );
fprintf(stderr, "END\n");
}
b_sleep = ( p_obj->i_waiting == 0 );
......
......@@ -54,6 +54,11 @@ playlist_item_t *playlist_RecursiveFindPrev( playlist_t *p_playlist,
void playlist_NodeDump( playlist_t *p_playlist, playlist_item_t *p_item,
int i_level );
int playlist_NodeDeleteInternal( playlist_t *p_playlist,
playlist_item_t *p_root,
vlc_bool_t b_delete_items, vlc_bool_t b_force );
/**********************************************************************
* Exported View management functions
**********************************************************************/
......@@ -122,6 +127,8 @@ int playlist_ViewInsert( playlist_t *p_playlist, int i_id, char *psz_name )
*/
int playlist_ViewDelete( playlist_t *p_playlist,playlist_view_t *p_view )
{
playlist_NodeDeleteInternal( p_playlist, p_view->p_root, VLC_TRUE,
VLC_TRUE );
REMOVE_ELEM( p_playlist->pp_views, p_playlist->i_views, 0 );
return VLC_SUCCESS;
}
......@@ -307,6 +314,8 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, int i_view,
/**
* Remove all the children of a node
*
* This function must be entered with the playlist lock
*
* \param p_playlist the playlist
* \param p_root the node
* \param b_delete_items do we have to delete the children items ?
......@@ -348,6 +357,14 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
*/
int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
vlc_bool_t b_delete_items )
{
return playlist_NodeDeleteInternal( p_playlist, p_root,
b_delete_items, VLC_FALSE );
}
int playlist_NodeDeleteInternal( playlist_t *p_playlist,
playlist_item_t *p_root,
vlc_bool_t b_delete_items, vlc_bool_t b_force )
{
int i;
if( p_root->i_children == -1 )
......@@ -370,9 +387,8 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
}
}
/* Delete the node */
if( p_root->i_flags & PLAYLIST_RO_FLAG )
if( p_root->i_flags & PLAYLIST_RO_FLAG && !b_force )
{
msg_Dbg( p_playlist, "unable to remove node, write-protected" );
}
else
{
......
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