]> git.sesse.net Git - vlc/commitdiff
Deprecate ugly and unsafe vlc_object_find_name()
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 19 Aug 2009 20:45:45 +0000 (23:45 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 19 Aug 2009 21:05:31 +0000 (00:05 +0300)
psz_object_name can only be read from the thread calling module_need()
for the current object. As an alternative, module_need() would have to
be called before vlc_object_attach(), which would break var_CreateGet*.

include/vlc_objects.h
src/misc/objects.c

index e2fda545a74b1e2f687b8e5728e28c239950f7a4..804fc2010fa30c480d13e582673fc4ce29b24509 100644 (file)
@@ -75,6 +75,9 @@ VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) );
 __attribute__((deprecated))
 #endif
 VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
+#if defined (__GNUC__) && !defined __cplusplus
+__attribute__((deprecated))
+#endif
 VLC_EXPORT( vlc_object_t *, vlc_object_find_name, ( vlc_object_t *, const char *, int ) );
 VLC_EXPORT( void *, __vlc_object_hold, ( vlc_object_t * ) );
 VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
index eea00ba1176f60d1277cb02f464c39479d4f6404..d10f61b344726a4b63556f9384195e059aece3a0 100644 (file)
@@ -477,6 +477,9 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this,
 {
     vlc_object_t *p_found;
 
+    /* Reading psz_object_name from a separate inhibits thread-safety.
+     * Use a libvlc address variable instead for that sort of things! */
+    msg_Warn( p_this, "%s(%s) is not safe!", __func__, psz_name );
     /* If have the requested name ourselves, don't look further */
     if( !(i_mode & FIND_STRICT)
         && p_this->psz_object_name