Skip to content

Commit

Permalink
X11: Fix segfault on SIGINT
Browse files Browse the repository at this point in the history
deinit_x11() was called too late, and it seems some libs like xinerama
and xcb-render add cleanup hooks but forget to remove them when they get
unloaded.
  • Loading branch information
mmuman committed Aug 12, 2023
1 parent a41d82b commit 75ef511
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/display-x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ bool display_output_x11::initialize() {
return true;
}

bool display_output_x11::shutdown() { return false; }
bool display_output_x11::shutdown() {
deinit_x11();
return false;
}

bool display_output_x11::main_loop_wait(double t) {
/* wait for X event or timeout */
Expand Down
3 changes: 1 addition & 2 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ static void update_workarea();
static Window find_desktop_window(Window *p_root, Window *p_desktop);
static Window find_subwindow(Window win, int w, int h);
static void init_x11();
static void deinit_x11();

/********************* <SETTINGS> ************************/
namespace priv {
Expand Down Expand Up @@ -275,7 +274,7 @@ static void init_x11() {
DBGP("leave init_x11()");
}

static void deinit_x11() {
void deinit_x11() {
if (display) {
DBGP("deinit_x11()");
XCloseDisplay(display);
Expand Down
1 change: 1 addition & 0 deletions src/x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void set_transparent_background(Window win);
void get_x11_desktop_info(Display *current_display, Atom atom);
void set_struts(int);
void x11_init_window(lua::state &l, bool own);
void deinit_x11();

#ifdef BUILD_XDBE
void xdbe_swap_buffers(void);
Expand Down

0 comments on commit 75ef511

Please sign in to comment.