From 8b61de26db061836100c9f059aa2ca66864f759c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Andr=C3=A9?= Date: Sat, 20 Mar 2010 19:16:08 +0100 Subject: [PATCH] Lua: do not click a button twice in a row 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 | 2 +- modules/misc/lua/extension_thread.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/misc/lua/extension.c b/modules/misc/lua/extension.c index 51769ca86c..5e67582986 100644 --- a/modules/misc/lua/extension.c +++ b/modules/misc/lua/extension.c @@ -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 ); diff --git a/modules/misc/lua/extension_thread.c b/modules/misc/lua/extension_thread.c index 1df3cf4cf3..024949def8 100644 --- a/modules/misc/lua/extension_thread.c +++ b/modules/misc/lua/extension_thread.c @@ -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 ) -- 2.39.5