From: Pierre d'Herbemont Date: Sun, 23 Mar 2008 00:15:54 +0000 (+0100) Subject: objects: Call vlc_object_join() automatically from vlc_object_destructor() if needed. X-Git-Tag: 0.9.0-test0~1941 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=05dc64af7e19036bbf6fa538345b5a2278a1d91f;p=vlc objects: Call vlc_object_join() automatically from vlc_object_destructor() if needed. interaction: No need to call vlc_object_join() now. --- diff --git a/src/interface/interaction.c b/src/interface/interaction.c index fab49f7f27..25bfda0053 100644 --- a/src/interface/interaction.c +++ b/src/interface/interaction.c @@ -47,7 +47,6 @@ static interaction_t * InteractionGet( vlc_object_t * ); static void InteractionSearchInterface( interaction_t * ); static void InteractionLoop( vlc_object_t * ); static void InteractionManage( interaction_t * ); -static void interaction_Destructor( vlc_object_t *p_interaction ); static interaction_dialog_t *DialogGetById( interaction_t* , int ); static void DialogDestroy( interaction_dialog_t * ); @@ -383,16 +382,9 @@ vlc_object_t * interaction_Init( libvlc_int_t *p_libvlc ) } } - vlc_object_set_destructor( p_interaction, interaction_Destructor ); - return VLC_OBJECT( p_interaction ); } -static void interaction_Destructor( vlc_object_t *p_interaction ) -{ - vlc_thread_join( p_interaction ); -} - /********************************************************************** * The following functions are local **********************************************************************/ diff --git a/src/misc/objects.c b/src/misc/objects.c index 5e68e89597..3b7c24bdd7 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -200,6 +200,7 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size, p_priv->i_refcount = 1; p_priv->pf_destructor = kVLCDestructor; + p_priv->b_thread = VLC_FALSE; p_new->p_parent = NULL; p_new->pp_children = NULL; p_new->i_children = 0; @@ -419,6 +420,10 @@ static void vlc_object_destroy( vlc_object_t *p_this ) /* Send a kill to the object's thread if applicable */ vlc_object_kill( p_this ); + /* If we are running on a thread, wait until it ends */ + if( p_priv->b_thread ) + vlc_thread_join( p_this ); + /* Call the custom "subclass" destructor */ if( p_priv->pf_destructor ) p_priv->pf_destructor( p_this );