[1/6] gdb/tui: convert a window handle `if` into an `assert`
Commit Message
It should only be possible to call tui_win_info::refresh_window on a
window with a valid tui_win_info::handle. To do otherwise would
suggest we're trying to draw to the screen a window which GDB doesn't
think is part of the current layout. Which is just wrong.
Currently tui_win_info::refresh_window guards its content with an
`if (handle != NULL)`, but this can be changed to an assert.
A similar assert can be added to
tui_source_window_base::refresh_window, there's no `if` in this
function, which only backs up the reasoning in the first paragraph.
There should be no user-visible changes after this commit.
---
gdb/tui/tui-wingeneral.c | 13 ++++++-------
gdb/tui/tui-winsource.c | 2 ++
2 files changed, 8 insertions(+), 7 deletions(-)
@@ -55,13 +55,12 @@ tui_batch_rendering::~tui_batch_rendering ()
void
tui_win_info::refresh_window ()
{
- if (handle != NULL)
- {
- if (suppress_output)
- wnoutrefresh (handle.get ());
- else
- wrefresh (handle.get ());
- }
+ gdb_assert (handle != nullptr);
+
+ if (suppress_output)
+ wnoutrefresh (handle.get ());
+ else
+ wrefresh (handle.get ());
}
/* Draw a border around the window. */
@@ -310,6 +310,8 @@ tui_source_window_base::refresh_window ()
{
TUI_SCOPED_DEBUG_START_END ("window `%s`", name ());
+ gdb_assert (handle != nullptr);
+
/* tui_win_info::refresh_window would draw the empty background window to
the screen, potentially creating a flicker. */
wnoutrefresh (handle.get ());