From 7c71c35797acba4c20d73fa907ca63b656c94b09 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Tue, 1 Jul 2014 14:55:59 -0400 Subject: [PATCH] possibly fix segfault --- src/windows.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/windows.c b/src/windows.c index 597889f..00c3e33 100644 --- a/src/windows.c +++ b/src/windows.c @@ -329,45 +329,41 @@ void on_window_resize(void) continue; } - ChatContext *ctx = w->chatwin; - - if (w->is_groupchat) - delwin(ctx->sidebar); - else - delwin(w->stb->topline); - - delwin(ctx->linewin); - delwin(ctx->history); delwin(w->window); - w->window = newwin(LINES - 2, COLS, 0, 0); int x2, y2, x, y; getmaxyx(w->window, y2, x2); - getyx(w->window, y, x); /* don't remove this */ w->x = x2; - ctx = w->chatwin; - ctx->linewin = subwin(w->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0); + if (w->is_groupchat) + delwin(w->chatwin->sidebar); + else + delwin(w->stb->topline); + + delwin(w->chatwin->linewin); + delwin(w->chatwin->history); + + w->chatwin->linewin = subwin(w->window, CHATBOX_HEIGHT, x2, y2 - CHATBOX_HEIGHT, 0); if (w->is_groupchat) { - ctx->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2 - SIDEBAR_WIDTH - 1, 0, 0); - ctx->sidebar = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, SIDEBAR_WIDTH, 0, x2 - SIDEBAR_WIDTH); + w->chatwin->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2 - SIDEBAR_WIDTH - 1, 0, 0); + w->chatwin->sidebar = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, SIDEBAR_WIDTH, 0, x2 - SIDEBAR_WIDTH); } else { - ctx->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0); + w->chatwin->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0); w->stb->topline = subwin(w->window, 2, x2, 0, 0); } #ifdef _SUPPORT_AUDIO - if (ctx->infobox.active) { - delwin(ctx->infobox.win); - ctx->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); + if (w->chatwin->infobox.active) { + delwin(w->chatwin->infobox.win); + w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); } #endif /* #ifdef _SUPPORT_AUDIO */ - scrollok(ctx->history, 0); + scrollok(w->chatwin->history, 0); } }