]> git.sesse.net Git - vlc/commitdiff
objects: Call vlc_object_join() automatically from vlc_object_destructor() if needed.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 23 Mar 2008 00:15:54 +0000 (01:15 +0100)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 23 Mar 2008 00:15:54 +0000 (01:15 +0100)
interaction: No need to call vlc_object_join() now.

src/interface/interaction.c
src/misc/objects.c

index fab49f7f27e02f266db8bfe3eaf47c7059a2c549..25bfda005354128b181d41bf69af1582cfe11142 100644 (file)
@@ -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
  **********************************************************************/
index 5e68e8959713993ea4a63c1e3c4846be667bd63b..3b7c24bdd79beaab76b945abceb97f351d3411d7 100644 (file)
@@ -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 );