]> git.sesse.net Git - vlc/commitdiff
Lua: do not click a button twice in a row
authorJean-Philippe André <jpeg@videolan.org>
Sat, 20 Mar 2010 18:16:08 +0000 (19:16 +0100)
committerJean-Philippe André <jpeg@videolan.org>
Sat, 20 Mar 2010 18:17:42 +0000 (19:17 +0100)
Fixes #3364 (big bug on buttons)
It is not possible to click the same button twice in a row (while the
script is actually running), but other buttons can be clicked.

modules/misc/lua/extension.c
modules/misc/lua/extension_thread.c

index 51769ca86c51dbb9362c07df4cc452359e4de420..5e6758298659e210bbeff2a037a6f5c503f24d2b 100644 (file)
@@ -988,7 +988,7 @@ static int vlclua_extension_dialog_callback( vlc_object_t *p_this,
     {
         case EXTENSION_EVENT_CLICK:
             assert( p_widget != NULL );
-            PushCommand( p_ext, CMD_CLICK, p_widget );
+            PushCommandUnique( p_ext, CMD_CLICK, p_widget );
             break;
         case EXTENSION_EVENT_CLOSE:
             PushCommandUnique( p_ext, CMD_CLOSE );
index 1df3cf4cf30a32311fcfc3da6ad4fca87d226396..024949def8a104d2cdf22b0b4d1b5c94ac78d00b 100644 (file)
@@ -267,7 +267,7 @@ int __PushCommand( extension_t *p_ext,  bool b_unique, int i_command,
             if( b_unique && last->i_command == i_command )
             {
                 // Do not push this 'unique' command a second time
-                b_skip = true;
+                b_skip = !memcmp( last->data, cmd->data, sizeof( cmd->data ) );
                 break;
             }
             else
@@ -276,7 +276,11 @@ int __PushCommand( extension_t *p_ext,  bool b_unique, int i_command,
             }
         }
         if( !b_skip )
-            last->next = cmd;
+        {
+            if( !b_unique || ( last->i_command != i_command )
+                || memcmp( last->data, cmd->data, sizeof( cmd->data ) ) != 0 )
+                last->next = cmd;
+        }
     }
 
     vlc_cond_signal( &p_ext->p_sys->wait );
@@ -296,12 +300,6 @@ static void* Run( void *data )
     {
         /* Pop command in front */
         struct command_t *cmd = p_ext->p_sys->command;
-        if( cmd )
-        {
-            p_ext->p_sys->command = cmd->next;
-            cmd->next = NULL; // This prevents FreeCommands from freeing next
-        }
-
         vlc_mutex_unlock( &p_ext->p_sys->command_lock );
 
         /* Run command */
@@ -394,7 +392,12 @@ static void* Run( void *data )
             }
         }
 
-        FreeCommands( cmd );
+        if( cmd )
+        {
+            p_ext->p_sys->command = cmd->next;
+            cmd->next = NULL; // This prevents FreeCommands from freeing next
+            FreeCommands( cmd );
+        }
 
         vlc_mutex_lock( &p_ext->p_sys->command_lock );
         if( !p_ext->p_sys->b_exiting && !p_ext->p_sys->command )