mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
Fix freeze/crash when sigwinch signal is received during refresh (for example if repaint is done during terminal resize)
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-command.h"
|
||||
@@ -87,7 +86,6 @@ gui_main_init ()
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
struct winsize size;
|
||||
|
||||
initscr ();
|
||||
|
||||
@@ -106,15 +104,7 @@ gui_main_init ()
|
||||
gui_term_cols = COLS;
|
||||
gui_term_lines = LINES;
|
||||
|
||||
if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0)
|
||||
{
|
||||
resizeterm(size.ws_row, size.ws_col);
|
||||
gui_term_cols = size.ws_col;
|
||||
gui_term_lines = size.ws_row;
|
||||
}
|
||||
|
||||
gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH)
|
||||
&& (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT));
|
||||
gui_window_read_terminal_size ();
|
||||
|
||||
/* init clipboard buffer */
|
||||
gui_input_clipboard = NULL;
|
||||
@@ -215,26 +205,7 @@ gui_main_signal_sighup ()
|
||||
void
|
||||
gui_main_signal_sigwinch ()
|
||||
{
|
||||
struct winsize size;
|
||||
int new_width, new_height;
|
||||
|
||||
if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0)
|
||||
{
|
||||
resizeterm (size.ws_row, size.ws_col);
|
||||
gui_term_cols = size.ws_col;
|
||||
gui_term_lines = size.ws_row;
|
||||
gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH)
|
||||
&& (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT));
|
||||
wrefresh (curscr);
|
||||
}
|
||||
else
|
||||
{
|
||||
getmaxyx (stdscr, new_height, new_width);
|
||||
gui_term_cols = new_width;
|
||||
gui_term_lines = new_height;
|
||||
}
|
||||
|
||||
gui_window_ask_refresh (1);
|
||||
gui_window_ask_refresh (2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-config.h"
|
||||
@@ -72,6 +73,33 @@ gui_window_get_height ()
|
||||
return gui_term_lines;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_read_terminal_size: read terminal size
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_read_terminal_size ()
|
||||
{
|
||||
struct winsize size;
|
||||
int new_width, new_height;
|
||||
|
||||
if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0)
|
||||
{
|
||||
resizeterm (size.ws_row, size.ws_col);
|
||||
gui_term_cols = size.ws_col;
|
||||
gui_term_lines = size.ws_row;
|
||||
}
|
||||
else
|
||||
{
|
||||
getmaxyx (stdscr, new_height, new_width);
|
||||
gui_term_cols = new_width;
|
||||
gui_term_lines = new_height;
|
||||
}
|
||||
|
||||
gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH)
|
||||
&& (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT));
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_objects_init: init Curses windows
|
||||
*/
|
||||
@@ -1322,21 +1350,21 @@ gui_window_switch_right (struct t_gui_window *window)
|
||||
|
||||
/*
|
||||
* gui_window_refresh_screen: called when term size is modified
|
||||
* full_refresh == 1 when Ctrl+L is pressed
|
||||
* full_refresh == 1 when Ctrl+L is pressed,
|
||||
* or if terminal is resized
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_refresh_screen (int full_refresh)
|
||||
{
|
||||
if (gui_ok)
|
||||
if (full_refresh)
|
||||
{
|
||||
if (full_refresh)
|
||||
{
|
||||
endwin ();
|
||||
refresh ();
|
||||
}
|
||||
gui_window_refresh_windows ();
|
||||
endwin ();
|
||||
refresh ();
|
||||
gui_window_read_terminal_size ();
|
||||
}
|
||||
|
||||
gui_window_refresh_windows ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -70,6 +70,7 @@ extern void gui_keyboard_default_bindings ();
|
||||
extern int gui_keyboard_read_cb (void *data, int fd);
|
||||
|
||||
/* window functions */
|
||||
extern void gui_window_read_terminal_size ();
|
||||
extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
|
||||
extern int gui_window_utf_char_valid (const char *utf_char);
|
||||
extern void gui_window_clear (WINDOW *window, int bg);
|
||||
|
||||
Reference in New Issue
Block a user