[vlc-devel] commit: Extensions: call lua_DialogFlush after Lua call ( Jean-Philippe André )

git version control git at videolan.org
Wed Feb 3 17:21:56 CET 2010


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Wed Feb  3 14:31:07 2010 +0100| [1f3bd0cc834eeade41efbea617c013cce70c93b7] | committer: Jean-Philippe André 

Extensions: call lua_DialogFlush after Lua call

This flushes the dialog (updates it at the UI level) after a Lua
function return.

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

 modules/misc/lua/extension.c        |    4 +++-
 modules/misc/lua/extension.h        |   23 +++++++++++++++++------
 modules/misc/lua/extension_thread.c |   11 ++---------
 modules/misc/lua/libs/dialog.c      |    9 +++++----
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/modules/misc/lua/extension.c b/modules/misc/lua/extension.c
index 0f7e506..5d377a3 100644
--- a/modules/misc/lua/extension.c
+++ b/modules/misc/lua/extension.c
@@ -144,6 +144,7 @@ void Close_Extension( vlc_object_t *p_this )
     FOREACH_ARRAY( p_ext, p_mgr->p_sys->activated_extensions )
     {
         if( !p_ext ) break;
+        msg_Dbg( p_mgr, "Deactivating '%s'", p_ext->psz_title );
         Deactivate( p_mgr, p_ext );
         WaitForDeactivation( p_ext );
     }
@@ -791,7 +792,7 @@ int lua_ExecuteFunction( extensions_manager_t *p_mgr,
         goto exit;
     }
 
-    i_ret = VLC_SUCCESS;
+    i_ret = lua_DialogFlush( L );
 exit:
     return i_ret;
 }
@@ -831,6 +832,7 @@ int lua_ExtensionTriggerMenu( extensions_manager_t *p_mgr,
         return VLC_EGENERIC;
     }
 
+    i_ret = lua_DialogFlush( L );
     if( i_ret < VLC_SUCCESS )
     {
         msg_Dbg( p_mgr, "Something went wrong in %s (%s:%d)",
diff --git a/modules/misc/lua/extension.h b/modules/misc/lua/extension.h
index dc5ca31..78928b5 100644
--- a/modules/misc/lua/extension.h
+++ b/modules/misc/lua/extension.h
@@ -90,12 +90,23 @@ int Activate( extensions_manager_t *p_mgr, extension_t * );
 bool IsActivated( extensions_manager_t *p_mgr, extension_t * );
 int Deactivate( extensions_manager_t *p_mgr, extension_t * );
 void WaitForDeactivation( extension_t *p_ext );
-int __PushCommand( extension_t *p_ext, bool b_unique,
-                   int i_command, ... );
-#define PushCommand( ext, cmd, ... ) \
-      __PushCommand( ext, false, cmd, ## __VA_ARGS__ )
-#define PushCommandUnique( ext, cmd, ... ) \
-      __PushCommand( ext, true, cmd, ## __VA_ARGS__ )
+int __PushCommand( extension_t *ext, bool unique, int cmd, va_list options );
+static inline int PushCommand( extension_t *ext, int cmd, ... )
+{
+    va_list args;
+    va_start( args, cmd );
+    int i_ret = __PushCommand( ext, false, cmd, args );
+    va_end( args );
+    return i_ret;
+}
+static inline int PushCommandUnique( extension_t *ext, int cmd, ... )
+{
+    va_list args;
+    va_start( args, cmd );
+    int i_ret = __PushCommand( ext, true, cmd, args );
+    va_end( args );
+    return i_ret;
+}
 bool LockExtension( extension_t *p_ext );
 void UnlockExtension( extension_t *p_ext );
 
diff --git a/modules/misc/lua/extension_thread.c b/modules/misc/lua/extension_thread.c
index c04b60a..ac3a459 100644
--- a/modules/misc/lua/extension_thread.c
+++ b/modules/misc/lua/extension_thread.c
@@ -204,16 +204,11 @@ void WaitForDeactivation( extension_t *p_ext )
 }
 
 /** Push a UI command */
-int __PushCommand( extension_t *p_ext,
-                   bool b_unique,
-                   int i_command,
-                   ... )
+int __PushCommand( extension_t *p_ext,  bool b_unique, int i_command,
+                   va_list args )
 {
     vlc_mutex_lock( &p_ext->p_sys->command_lock );
 
-    va_list args;
-    va_start( args, i_command );
-
     /* Create command */
     struct command_t *cmd = calloc( 1, sizeof( struct command_t ) );
     cmd->i_command = i_command;
@@ -246,8 +241,6 @@ int __PushCommand( extension_t *p_ext,
             break;
     }
 
-    va_end( args );
-
     /* Push command to the end of the queue */
     struct command_t *last = p_ext->p_sys->command;
     if( !last )
diff --git a/modules/misc/lua/libs/dialog.c b/modules/misc/lua/libs/dialog.c
index 0ef1777..e38faa9 100644
--- a/modules/misc/lua/libs/dialog.c
+++ b/modules/misc/lua/libs/dialog.c
@@ -53,8 +53,9 @@ static int vlclua_dialog_delete( lua_State *L );
 static int vlclua_dialog_show( lua_State *L );
 static int vlclua_dialog_hide( lua_State *L );
 static int vlclua_dialog_flush( lua_State *L );
-static void lua_SetDialogUpdate( lua_State *L, int flag )
-static int lua_GetDialogUpdate( lua_State *L )
+static void lua_SetDialogUpdate( lua_State *L, int flag );
+static int lua_GetDialogUpdate( lua_State *L );
+int lua_DialogFlush( lua_State *L );
 
 static int vlclua_dialog_add_button( lua_State *L );
 static int vlclua_dialog_add_label( lua_State *L );
@@ -347,7 +348,7 @@ static void lua_SetDialogUpdate( lua_State *L, int flag )
     /* Set entry in the Lua registry */
     lua_pushlightuserdata( L, (void*) &key_update );
     lua_pushinteger( L, flag );
-    lua_settable( L, LUA_REGISTRYINDEX ); 
+    lua_settable( L, LUA_REGISTRYINDEX );
 }
 
 static int lua_GetDialogUpdate( lua_State *L )
@@ -368,7 +369,7 @@ int lua_DialogFlush( lua_State *L )
 {
     lua_getglobal( L, "vlc" );
     lua_getfield( L, -1, "__dialog" );
-    extension_dialog_t *p_dlg = ( extension_dialog*t )
+    extension_dialog_t *p_dlg = ( extension_dialog_t* )
             lua_topointer( L, lua_gettop( L ) );
 
     if( !p_dlg )




More information about the vlc-devel mailing list