]> git.sesse.net Git - vlc/commitdiff
Input: attach before any variable access so that inheritance works
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 18 Jan 2010 18:06:27 +0000 (20:06 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 18 Jan 2010 18:12:45 +0000 (20:12 +0200)
So far, the input was attached after it inherited quite a bunch of
variables. This did not quite work. The problem lies in the dual use
of object attachment: variables inheritance and tree search.

Nowadays, the input object should not be looked for before it is
initialized. Only children objects use vlc_object_find anymore, and
they can only exist while the input is fully initialized. Other code
paths use playlist_CurrentInput() or such, which only ever return an
already initialized input (from input.c:Create()).

(N.B.: I wonder if there aren't similar issues in VOUT and AOUT)

src/input/input.c

index 0f09556d632a31693d26ee95f2623e14820f1d45..2269ead3a4566050341e85e62dc0d5738879d4d8 100644 (file)
@@ -312,6 +312,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     if( p_input == NULL )
         return NULL;
 
+    vlc_object_attach( p_input, p_parent );
+
     /* Construct a nice name for the input timer */
     char psz_timer_name[255];
     char * psz_name = input_item_GetName( p_item );
@@ -478,9 +480,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     /* Set the destructor when we are sure we are initialized */
     vlc_object_set_destructor( p_input, (vlc_destructor_t)Destructor );
 
-    /* Attach only once we are ready */
-    vlc_object_attach( p_input, p_parent );
-
     return p_input;
 }