From f49b95c6b5e565dc4fdf1243823ae8219e46a944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 12 Aug 2023 02:23:45 +0200 Subject: [PATCH] X11: Fix segfault on SIGINT 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. --- src/display-x11.cc | 5 ++++- src/x11.cc | 3 +-- src/x11.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/display-x11.cc b/src/display-x11.cc index fb8ef72fc6..61d47200bd 100644 --- a/src/display-x11.cc +++ b/src/display-x11.cc @@ -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 true; +} bool display_output_x11::main_loop_wait(double t) { /* wait for X event or timeout */ diff --git a/src/x11.cc b/src/x11.cc index 771a9c8ac7..b0dd8e6901 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -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(); /********************* ************************/ namespace priv { @@ -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); diff --git a/src/x11.h b/src/x11.h index eeef2be1e9..6431e4c3b7 100644 --- a/src/x11.h +++ b/src/x11.h @@ -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);