From: RĂ©mi Denis-Courmont Date: Wed, 19 Aug 2009 20:45:45 +0000 (+0300) Subject: Deprecate ugly and unsafe vlc_object_find_name() X-Git-Tag: 1.1.0-ff~4204 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b6c76ecf1a1b2c87d8dc91e0a636291339d96c28;p=vlc Deprecate ugly and unsafe vlc_object_find_name() 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*. --- diff --git a/include/vlc_objects.h b/include/vlc_objects.h index e2fda545a7..804fc2010f 100644 --- a/include/vlc_objects.h +++ b/include/vlc_objects.h @@ -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 * ) ); diff --git a/src/misc/objects.c b/src/misc/objects.c index eea00ba117..d10f61b344 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -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