[binutils-gdb] [gdb/tui] Allow second tui enable if first fails
Tom de Vries via Gdb-cvs <[email protected]> Wed, 20 May 2026 06:31:28 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8822682db0b86fcbf16b41397424cd78d48c924d commit 8822682db0b86fcbf16b41397424cd78d48c924d Author: Tom de Vries <[email protected]> Date: Wed May 20 08:31:12 2026 +0200 [gdb/tui] Allow second tui enable if first fails 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 <[email protected]> Diff: --- gdb/tui/tui-wingeneral.c | 2 +- gdb/tui/tui.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index 86f13d275b4..149ca4efc6e 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -46,7 +46,7 @@ tui_batch_rendering::tui_batch_rendering () tui_batch_rendering::~tui_batch_rendering () { suppress_output = m_saved_suppress; - if (!suppress_output) + if (!suppress_output && tui_active) doupdate (); } diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 11bcba813bc..958fc47b7b6 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -494,7 +494,7 @@ tui_enable (void) /* Don't try initialization again. */ tui_finish_init = TRIBOOL_UNKNOWN; - SCREEN *s = init_ncurses (); + init_ncurses (); w = stdscr; if (has_colors ()) @@ -532,8 +532,13 @@ tui_enable (void) 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; }