changeset 37032:4c7ab9a4f3cd

vf_menu: try to make code more straight-forward.
author reimar
date Sun, 06 Apr 2014 17:57:33 +0000
parents 2c8fbf453871
children de0c74742689
files libmenu/vf_menu.c
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/vf_menu.c	Sun Apr 06 17:56:13 2014 +0000
+++ b/libmenu/vf_menu.c	Sun Apr 06 17:57:33 2014 +0000
@@ -103,16 +103,14 @@
     return 1;
   }
   case MP_CMD_SET_MENU : {
-    char* menu = cmd->args[0].v.s;
-    menu_t* l = priv->current;
-    priv->current = menu_open(menu);
-    if(!priv->current) {
+    const char *menu = cmd->args[0].v.s;
+    menu_t *new = menu_open(menu);
+    priv->current->show = new != NULL;
+    if (new) {
+      new->parent = priv->current;
+      priv->current = new;
+    } else {
       mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu);
-      priv->current = l;
-      priv->current->show = 0;
-    } else {
-      priv->current->show = 1;
-      priv->current->parent = l;
     }
     return 1;
   }