Commit
fb23d7ba4a2 ("[gdb/tui] Handle error in tui_enable") handles a
particular error during tui_enable, but doesn't allow trying to enable TUI
again.
I tried to get this to work, but didn't manage because I didn't understand the
interaction between endwin and the "tui_batch_rendering defer" destructor:
- first endwin restores the shell terminal mode
- then the defer destructor calls doupdate, restoring program terminal mode.
Fix this by checking for tui_active in ~tui_batch_rendering.
Approved-By: Tom Tromey <tom@tromey.com>
tui_batch_rendering::~tui_batch_rendering ()
{
suppress_output = m_saved_suppress;
- if (!suppress_output)
+ if (!suppress_output && tui_active)
doupdate ();
}
/* Don't try initialization again. */
tui_finish_init = TRIBOOL_UNKNOWN;
- SCREEN *s = init_ncurses ();
+ init_ncurses ();
w = stdscr;
if (has_colors ())
catch (const gdb_exception &)
{
endwin ();
- delscreen (s);
+
+ /* Initialization failed, so TUI is not active. */
tui_active = false;
+
+ /* Allow trying to initialize TUI again. */
+ tui_finish_init = TRIBOOL_TRUE;
+
throw;
}