[vlc-commits] Qt4: improve macro expansion safety

Rémi Denis-Courmont git at videolan.org
Sat Jan 4 22:09:51 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan  4 22:50:39 2014 +0200| [0a232d66f06f065a29b0b393da8a31b900ca868c] | committer: Rémi Denis-Courmont

Qt4: improve macro expansion safety

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

 modules/gui/qt4/menus.cpp |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 688306f..116fc1e 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -210,11 +210,14 @@ static QAction * FindActionWithVar( QMenu *menu, const char *psz_var )
 /*****************************************************************************
  * Definitions of variables for the dynamic menus
  *****************************************************************************/
-#define PUSH_VAR( var ) varnames.append( var ); \
-    objects.append( VLC_OBJECT(p_object) )
-
-#define PUSH_INPUTVAR( var ) varnames.append( var ); \
-    objects.append( VLC_OBJECT(p_input) );
+#define PUSH_OBJVAR(object,var) \
+    do { \
+        varnames.append(var); \
+        objects.append(VLC_OBJECT(object)); \
+    } while (0)
+
+#define PUSH_VAR(var) PUSH_OBJVAR(p_object, var)
+#define PUSH_INPUTVAR(var) PUSH_OBJVAR(p_input, var)
 
 static int InputAutoMenuBuilder( input_thread_t *p_object,
         QVector<vlc_object_t *> &objects,



More information about the vlc-commits mailing list