[vlc-devel] commit: objects: Make sure that we don't loose a vlc_object_kill() when attaching to a dead or dying parent. (Pierre d'Herbemont )

git version control git at videolan.org
Fri May 30 14:18:36 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri May 30 14:18:02 2008 +0200| [a9565f33d3e6742d5a18c8a0e6b8d811d95cc885]

objects: Make sure that we don't loose a vlc_object_kill() when attaching to a dead or dying parent.

Note: We do need to lock the parent for that.

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

 src/misc/objects.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 36f9159..d4a5a6b 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -837,11 +837,19 @@ void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
     assert (!p_this->p_parent);
     p_this->p_parent = p_parent;
 
+    vlc_object_lock( p_this->p_parent );
+
     /* Attach the child to its parent */
     vlc_object_internals_t *priv = vlc_internals( p_parent );
     INSERT_ELEM( priv->pp_children, priv->i_children, priv->i_children,
                  p_this );
 
+    /* Kill the object if parent is already dead */
+    if( !vlc_object_alive( p_this->p_parent) )
+        vlc_object_kill( p_this );
+
+    vlc_object_unlock( p_this->p_parent );
+
     vlc_mutex_unlock( &structure_lock );
 }
 




More information about the vlc-devel mailing list