TTY_PERM_INVENT crash fix

The change 3 weeks ago for #4059 (to fix tty perm_invent memory leak)
resulted in nethack crashing during exit if built with TTY_PERM_INVENT
enabled and ending the game when perm_invent window isn't displayed.

This exits cleanly with or without perm_invent being shown and avoids
the memory leak which triggered the prior change.
This commit is contained in:
PatR
2023-12-28 14:25:39 -08:00
parent 073b0c90f3
commit 36c5843103

View File

@@ -1094,7 +1094,7 @@ tty_clear_nhwindow(winid window)
if (cw->active)
erase_menu_or_text(window, cw, TRUE);
#ifdef TTY_PERM_INVENT
if (window == WIN_INVEN)
if (cw->type == NHW_MENU && cw->mbehavior == MENU_BEHAVE_PERMINV)
ttyinv_remove_data(cw, FALSE);
else
#endif
@@ -1989,7 +1989,7 @@ tty_destroy_nhwindow(winid window)
if (cw->type == NHW_MAP)
term_clear_screen();
#ifdef TTY_PERM_INVENT
if (cw->type == NHW_PERMINVENT || window == WIN_INVEN)
if (cw->type == NHW_MENU && cw->mbehavior == MENU_BEHAVE_PERMINV)
ttyinv_remove_data(cw, TRUE);
#endif
free_window_info(cw, TRUE);