diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2018-03-26 12:46:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-26 12:46:04 +0200 |
commit | 7fc59d2d1016e28eced6dbcaddc1e1865fe0ebe8 (patch) | |
tree | e8225ec8feeb8429f3b9636e222bd07938b524c4 /src/fe-text/gui-printtext.c | |
parent | 191e0ac84ed42b51395ff9659b4f6169a1fcb3aa (diff) | |
parent | c7ca8102c002287f492ca71f2193ee9b269f5bf5 (diff) | |
download | irssi-7fc59d2d1016e28eced6dbcaddc1e1865fe0ebe8.zip |
Merge pull request #862 from ailin-nemui/line_is_null
fix a crash when trying to append to a NULL line
Diffstat (limited to 'src/fe-text/gui-printtext.c')
-rw-r--r-- | src/fe-text/gui-printtext.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index c52f9ced..83a36f14 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -120,12 +120,19 @@ void gui_printtext_internal(int xpos, int ypos, const char *str) next_xpos = next_ypos = -1; } +static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line); + void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str, time_t time) { GUI_WINDOW_REC *gui; gui = WINDOW_GUI(dest->window); + if (prev == NULL && !gui->view->buffer->last_eol) { + /* we have an unfinished line in the buffer still */ + view_add_eol(gui->view, &gui->insert_after); + } + gui->use_insert_after = TRUE; gui->insert_after = prev; gui->insert_after_time = time; @@ -249,9 +256,26 @@ static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line) textbuffer_view_insert_line(view, *line); } +static void print_text_no_window(int flags, int fg, int bg, int attr, const char *str) +{ + g_return_if_fail(next_xpos != -1); + + term_set_color2(root_window, attr, fg, bg); + + term_move(root_window, next_xpos, next_ypos); + if (flags & GUI_PRINT_FLAG_CLRTOEOL) { + if (clrtoeol_info->window != NULL) { + term_window_clrtoeol_abs(clrtoeol_info->window, next_ypos); + } else { + term_clrtoeol(root_window); + } + } + next_xpos += term_addstr(root_window, str); +} + static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, - char *str, TEXT_DEST_REC *dest) + const char *str, TEXT_DEST_REC *dest) { GUI_WINDOW_REC *gui; TEXT_BUFFER_VIEW_REC *view; @@ -265,19 +289,7 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, get_colors(flags, &fg, &bg, &attr); if (window == NULL) { - g_return_if_fail(next_xpos != -1); - - term_set_color2(root_window, attr, fg, bg); - - term_move(root_window, next_xpos, next_ypos); - if (flags & GUI_PRINT_FLAG_CLRTOEOL) { - if (clrtoeol_info->window != NULL) { - term_window_clrtoeol_abs(clrtoeol_info->window, next_ypos); - } else { - term_clrtoeol(root_window); - } - } - next_xpos += term_addstr(root_window, str); + print_text_no_window(flags, fg, bg, attr, str); return; } |