ncurses: avoid refering to dead NCursesUI in signal handler

This commit is contained in:
Maxime Coste 2012-11-27 18:54:27 +01:00
parent 4c1b48e314
commit 3a4859ecba

View File

@ -78,6 +78,9 @@ static void set_color(Color fg_color, Color bg_color)
static NCursesUI* signal_ui = nullptr;
void on_term_resize(int)
{
if (not signal_ui)
return;
int fd = open("/dev/tty", O_RDWR);
winsize ws;
if (fd == -1 or ioctl(fd, TIOCGWINSZ, (void*)&ws) != 0)
@ -123,6 +126,8 @@ NCursesUI::NCursesUI()
NCursesUI::~NCursesUI()
{
endwin();
assert(signal_ui == this);
signal_ui = nullptr;
}
static void redraw(WINDOW* menu_win)