ref: 8c20e0eb8b38aa0bdcb50d9af2e9a6839d9f143c
parent: e2925cf8e9c0cce95f4af05b63aa7c1484689d3d
author: cancel <cancel@cancel.fm>
date: Sat Jan 4 22:32:23 EST 2020
Add avoidance of 0-item ncurses menus being created
--- a/term_util.c
+++ b/term_util.c
@@ -262,6 +262,13 @@
set_menu_grey(qm->ncurses_menu, active ? A_DIM : A_DIM);
}
void qmenu_push_to_nav(Qmenu* qm) {
+ // new_menu() will get angry if there are no items in the menu. We'll get a
+ // null pointer back, and our code will get angry. Instead, just add an empty
+ // spacer item. This will probably only ever occur as a programming error,
+ // but we should try to avoid having to deal with qmenu_push_to_nav()
+ // returning a non-ignorable error for now.
+ if (qm->ncurses_items[0] == NULL)
+ qmenu_add_spacer(qm);
qm->ncurses_menu = new_menu(qm->ncurses_items);
set_menu_mark(qm->ncurses_menu, " > ");
set_menu_fore(qm->ncurses_menu, A_BOLD);