[vlc-commits] commit: Remove support for reparenting ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Tue May 25 22:52:27 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 25 23:45:43 2010 +0300| [07dd8683aa2ec200e25a373c1f390f7fa3097b8d] | committer: Rémi Denis-Courmont 

Remove support for reparenting

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

 src/libvlc.h       |    1 -
 src/misc/objects.c |   29 +----------------------------
 2 files changed, 1 insertions(+), 29 deletions(-)

diff --git a/src/libvlc.h b/src/libvlc.h
index 4af6d82..a9fd3d1 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -161,7 +161,6 @@ struct vlc_object_internals
     vlc_object_internals_t *next;  /* next sibling */
     vlc_object_internals_t *prev;  /* previous sibling */
     vlc_object_internals_t *first; /* first child */
-    vlc_object_t   *old_parent;
 };
 
 #define ZOOM_SECTION N_("Zoom")
diff --git a/src/misc/objects.c b/src/misc/objects.c
index d4a808c..9b8cb98 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -159,9 +159,6 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
     p_priv->b_thread = false;
     p_new->p_parent = NULL;
     p_priv->first = NULL;
-#ifndef NDEBUG
-    p_priv->old_parent = NULL;
-#endif
 
     /* Initialize mutexes and condvars */
     vlc_mutex_init( &p_priv->var_lock );
@@ -623,31 +620,13 @@ void vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
 
     vlc_object_internals_t *pap = vlc_internals (p_parent);
     vlc_object_internals_t *priv = vlc_internals (p_this);
-    vlc_object_t *p_old_parent;
 
     priv->prev = NULL;
     vlc_object_hold (p_parent);
     libvlc_lock (p_this->p_libvlc);
-#ifndef NDEBUG
-    /* Reparenting an object carries a risk of invalid access to the parent,
-     * from another thread. This can happen when inheriting a variable, or
-     * through any direct access to vlc_object_t.p_parent. Also, reparenting
-     * brings a functional bug, whereby the reparented object uses incorrect
-     * old values for inherited variables (as the new parent may have different
-     * variable values, especially if it is an input).
-     * Note that the old parent may be already destroyed.
-     * So its pointer must not be dereferenced.
-     */
-    if (priv->old_parent)
-        msg_Info (p_this, "Reparenting an object is dangerous (%p -> %p)!",
-                  priv->old_parent, p_parent);
-#endif
-
-    p_old_parent = p_this->p_parent;
-    if (p_old_parent)
-        vlc_object_detach_unlocked (p_this);
 
     /* Attach the parent to its child */
+    assert (p_this->p_parent == NULL);
     p_this->p_parent = p_parent;
 
     /* Attach the child to its parent */
@@ -656,9 +635,6 @@ void vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
         priv->next->prev = priv;
     pap->first = priv;
     libvlc_unlock (p_this->p_libvlc);
-
-    if (p_old_parent)
-        vlc_object_release (p_old_parent);
 }
 
 
@@ -678,9 +654,6 @@ static void vlc_object_detach_unlocked (vlc_object_t *p_this)
         priv->next->prev = priv->prev;
 
     /* Remove p_this's parent */
-#ifndef NDEBUG
-    priv->old_parent = p_this->p_parent;
-#endif
     p_this->p_parent = NULL;
 }
 



More information about the vlc-commits mailing list