[vlc-commits] commit: lua_variables: call only one time var_Type and corretly check the variable class. ( =?UTF-8?Q?R=C3=A9mi=20Duraffort=20?=)

git at videolan.org git at videolan.org
Thu Dec 2 18:07:51 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Dec  2 18:07:17 2010 +0100| [b43a83e5fe107d38d070ef8df01ffb91e5227473] | committer: Rémi Duraffort 

lua_variables: call only one time var_Type and corretly check the variable class.

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

 modules/misc/lua/libs/variables.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/misc/lua/libs/variables.c b/modules/misc/lua/libs/variables.c
index 0c98b53..37bfcd2 100644
--- a/modules/misc/lua/libs/variables.c
+++ b/modules/misc/lua/libs/variables.c
@@ -343,8 +343,10 @@ static int vlclua_add_callback( lua_State *L )
     if( !pp_obj || !*pp_obj )
         return vlclua_error( L );
 
+    int i_type = var_Type( *pp_obj, psz_var );
+
     /* Check variable type, in order to avoid PANIC */
-    switch( var_Type( *pp_obj, psz_var ) )
+    switch( i_type & VLC_VAR_CLASS )
     {
         case VLC_VAR_BOOL:
         case VLC_VAR_INTEGER:
@@ -415,7 +417,7 @@ static int vlclua_add_callback( lua_State *L )
     /* Do not move this before the lua specific code (it somehow changes
      * the function in the stack to nil) */
     p_callback->i_index = i_index;
-    p_callback->i_type = var_Type( *pp_obj, psz_var );
+    p_callback->i_type = i_type;
     p_callback->L = lua_newthread( L ); /* Do we have to keep a reference to this thread somewhere to prevent garbage collection? */
 
     var_AddCallback( *pp_obj, psz_var, vlclua_callback, p_callback );



More information about the vlc-commits mailing list