summaryrefslogtreecommitdiff
path: root/src/gui/curses
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-11-11 11:03:11 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-11-11 11:03:11 +0100
commit0c68d46f3b34489fa37270204ca22d2a39d5de49 (patch)
treed01cad7c22cbaa8830769d4d7aae08785f04405e /src/gui/curses
parentcecc1f9ea7aac5ef3486a9792e3cb3a899b4c3b5 (diff)
downloadweechat-0c68d46f3b34489fa37270204ca22d2a39d5de49.zip
Fix infinite loop when chat window is too small or not visible at all
Diffstat (limited to 'src/gui/curses')
-rw-r--r--src/gui/curses/gui-curses-window.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index defe8e3f1..71bf2b1d9 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -364,9 +364,13 @@ gui_window_calculate_pos_size (struct t_gui_window *window)
{
struct t_gui_bar_window *ptr_bar_win;
int add_top, add_bottom, add_left, add_right;
-
- if (!gui_ok)
+
+ if ((window->win_width < GUI_WINDOW_MIN_WIDTH)
+ || (window->win_height < GUI_WINDOW_MIN_HEIGHT))
+ {
+ gui_ok = 0;
return;
+ }
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
@@ -385,6 +389,9 @@ gui_window_calculate_pos_size (struct t_gui_window *window)
window->win_chat_height = window->win_height - add_top - add_bottom;
window->win_chat_cursor_x = window->win_x + add_left;
window->win_chat_cursor_y = window->win_y + add_top;
+
+ if ((window->win_chat_width <= 1) || (window->win_chat_height <= 0))
+ gui_ok = 0;
}
/*
@@ -487,30 +494,33 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
}
gui_window_calculate_pos_size (window);
-
- /* create bar windows */
- for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
- ptr_bar_win = ptr_bar_win->next_bar_window)
+
+ if (gui_ok)
{
- gui_bar_window_create_win (ptr_bar_win);
+ /* create bar windows */
+ for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
+ ptr_bar_win = ptr_bar_win->next_bar_window)
+ {
+ gui_bar_window_create_win (ptr_bar_win);
+ }
+
+ /* destroy Curses windows */
+ gui_window_objects_free (window, 0, 0);
+
+ /* create Curses windows */
+ if (GUI_CURSES(window)->win_chat)
+ delwin (GUI_CURSES(window)->win_chat);
+ GUI_CURSES(window)->win_chat = newwin (window->win_chat_height,
+ window->win_chat_width,
+ window->win_chat_y,
+ window->win_chat_x);
}
- /* destroy Curses windows */
- gui_window_objects_free (window, 0, 0);
-
- /* create Curses windows */
- if (GUI_CURSES(window)->win_chat)
- delwin (GUI_CURSES(window)->win_chat);
- GUI_CURSES(window)->win_chat = newwin (window->win_chat_height,
- window->win_chat_width,
- window->win_chat_y,
- window->win_chat_x);
-
buffer->num_displayed++;
gui_hotlist_remove_buffer (buffer);
-
- if (buffer != old_buffer)
+
+ if (gui_ok && (buffer != old_buffer))
{
gui_bar_window_remove_unused_bars (window);
gui_bar_window_add_missing_bars (window);