From 632d2cb79c1236b67987abaeeb303dc4530568d2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 24 Jul 2021 00:28:49 +0900 Subject: [PATCH] [console] Plug another escape handler leak --- libs/console/menu.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/console/menu.c b/libs/console/menu.c index 7dae05b97..f9b96fda7 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -359,6 +359,12 @@ bi_Menu_TopMenu (progs_t *pr) top_menu = strdup (name); } +static void +menu_leave (void *data) +{ + Menu_Leave (); +} + static void bi_Menu_SelectMenu (progs_t *pr) { @@ -368,7 +374,11 @@ bi_Menu_SelectMenu (progs_t *pr) if (name && *name) menu = Hash_Find (menu_hash, name); if (menu) { - Key_SetKeyDest (key_menu); + if (Key_GetKeyDest () != key_menu) { + menu_keydest = Key_GetKeyDest (); + Key_PushEscape (menu_leave, 0); + Key_SetKeyDest (key_menu); + } if (menu->enter_hook) { run_menu_pre (); PR_ExecuteProgram (&menu_pr_state, menu->enter_hook); @@ -377,7 +387,7 @@ bi_Menu_SelectMenu (progs_t *pr) } else { if (name && *name) Sys_Printf ("no menu \"%s\"\n", name); - Key_PopEscape (); + Key_PopEscape (); Key_SetKeyDest (menu_keydest); } } @@ -463,6 +473,7 @@ bi_Menu_Leave (progs_t *pr) } menu = menu->parent; if (!menu) { + Key_PopEscape (); Key_SetKeyDest (menu_keydest); } } @@ -780,12 +791,6 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down) } } -static void -menu_leave (void *data) -{ - Menu_Leave (); -} - void Menu_Enter () {