]> git.sesse.net Git - vlc/blobdiff - src/misc/variables.c
Fix menu removal of accelerators. This has yet to be more FIXMEd (jpeg :D)
[vlc] / src / misc / variables.c
index 2c2a789aa9868ecd961f0a2cf2c08b7b97deaa1c..ed5f31a03d50b9ae628a9b45f85a7782f04ade39 100644 (file)
@@ -28,7 +28,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include "variables.h"
 
 #include "libvlc.h"
@@ -168,6 +168,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
     static vlc_list_t dummy_null_list = {0, NULL, NULL};
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     /* FIXME: if the variable already exists, we don't duplicate it. But we
@@ -331,6 +332,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
     variable_t *p_var;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     i_var = GetUnused( p_this, psz_name );
@@ -407,6 +409,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
     vlc_value_t oldval;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
@@ -470,22 +473,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             }
             break;
         case VLC_VAR_ADDCHOICE:
-            /* FIXME: the list is sorted, dude. Use something cleverer. */
-            for( i = p_var->choices.i_count ; i-- ; )
-            {
-                if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) < 0 )
-                {
-                    break;
-                }
-            }
-
-            /* The new place is i+1 */
-            i++;
-
-            if( p_var->i_default >= i )
-            {
-                p_var->i_default++;
-            }
+            i = p_var->choices.i_count;
 
             INSERT_ELEM( p_var->choices.p_values, p_var->choices.i_count,
                          i, *p_val );
@@ -499,7 +487,6 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             CheckValue( p_var, &p_var->val );
             break;
         case VLC_VAR_DELCHOICE:
-            /* FIXME: the list is sorted, dude. Use something cleverer. */
             for( i = 0 ; i < p_var->choices.i_count ; i++ )
             {
                 if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 )
@@ -707,6 +694,10 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
             }
             break;
 
+        case VLC_VAR_SETISCOMMAND:
+            p_var->i_type |= VLC_VAR_ISCOMMAND;
+            break;
+
         default:
             break;
     }
@@ -759,6 +750,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
     vlc_value_t oldval;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     i_var = GetUnused( p_this, psz_name );
@@ -836,6 +828,7 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
     variable_t *p_var;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
@@ -902,6 +895,7 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
     callback_entry_t entry;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     entry.pf_callback = pf_callback;
     entry.p_data = p_data;
 
@@ -939,6 +933,7 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
     variable_t *p_var;
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
 
+    vlc_refcheck( p_this );
     vlc_mutex_lock( &p_priv->var_lock );
 
     i_var = GetUnused( p_this, psz_name );
@@ -1575,6 +1570,7 @@ int __var_Command( vlc_object_t *p_this, const char *psz_name,
         return VLC_ENOOBJ;
     }
 
+    vlc_refcheck( p_this );
     i_type = var_Type( p_obj, psz_cmd );
     if( !( i_type&VLC_VAR_ISCOMMAND ) )
     {