[vlc-devel] commit: objects: Call vlc_object_join() automatically from vlc_object_destructor() if needed. (Pierre d'Herbemont )

git version control git at videolan.org
Sun Mar 23 01:16:22 CET 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Sun Mar 23 01:15:54 2008 +0100| [05dc64af7e19036bbf6fa538345b5a2278a1d91f]

objects: Call vlc_object_join() automatically from vlc_object_destructor() if needed.
interaction: No need to call vlc_object_join() now.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05dc64af7e19036bbf6fa538345b5a2278a1d91f
---

 src/interface/interaction.c |    8 --------
 src/misc/objects.c          |    5 +++++
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/interface/interaction.c b/src/interface/interaction.c
index fab49f7..25bfda0 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 5e68e89..3b7c24b 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 );




More information about the vlc-devel mailing list