mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-20 06:59:42 -05:00
xwayland/xwm: listen shell destroy signal
Otherwise we got invaild write in wl_list_remove. Fixes:e209fe2d0("Fix memory leak in xwayland.c") Signed-off-by: zhoulei <zhoulei@kylinos.cn> (cherry picked from commit2c64f36e88)
This commit is contained in:
parent
4900daa787
commit
0992422493
2 changed files with 15 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ struct wlr_xwm {
|
||||||
struct wl_listener compositor_new_surface;
|
struct wl_listener compositor_new_surface;
|
||||||
struct wl_listener compositor_destroy;
|
struct wl_listener compositor_destroy;
|
||||||
struct wl_listener shell_v1_new_surface;
|
struct wl_listener shell_v1_new_surface;
|
||||||
|
struct wl_listener shell_v1_destroy;
|
||||||
struct wl_listener seat_set_selection;
|
struct wl_listener seat_set_selection;
|
||||||
struct wl_listener seat_set_primary_selection;
|
struct wl_listener seat_set_primary_selection;
|
||||||
struct wl_listener seat_start_drag;
|
struct wl_listener seat_start_drag;
|
||||||
|
|
|
||||||
|
|
@ -1786,6 +1786,16 @@ static void handle_shell_v1_new_surface(struct wl_listener *listener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_shell_v1_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_xwm *xwm =
|
||||||
|
wl_container_of(listener, xwm, shell_v1_destroy);
|
||||||
|
wl_list_remove(&xwm->shell_v1_new_surface.link);
|
||||||
|
wl_list_remove(&xwm->shell_v1_destroy.link);
|
||||||
|
wl_list_init(&xwm->shell_v1_new_surface.link);
|
||||||
|
wl_list_init(&xwm->shell_v1_destroy.link);
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface,
|
void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface,
|
||||||
bool activated) {
|
bool activated) {
|
||||||
struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface;
|
struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface;
|
||||||
|
|
@ -1913,6 +1923,7 @@ void xwm_destroy(struct wlr_xwm *xwm) {
|
||||||
wl_list_remove(&xwm->compositor_new_surface.link);
|
wl_list_remove(&xwm->compositor_new_surface.link);
|
||||||
wl_list_remove(&xwm->compositor_destroy.link);
|
wl_list_remove(&xwm->compositor_destroy.link);
|
||||||
wl_list_remove(&xwm->shell_v1_new_surface.link);
|
wl_list_remove(&xwm->shell_v1_new_surface.link);
|
||||||
|
wl_list_remove(&xwm->shell_v1_destroy.link);
|
||||||
xcb_disconnect(xwm->xcb_conn);
|
xcb_disconnect(xwm->xcb_conn);
|
||||||
|
|
||||||
struct pending_startup_id *pending, *next;
|
struct pending_startup_id *pending, *next;
|
||||||
|
|
@ -2257,6 +2268,9 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) {
|
||||||
xwm->shell_v1_new_surface.notify = handle_shell_v1_new_surface;
|
xwm->shell_v1_new_surface.notify = handle_shell_v1_new_surface;
|
||||||
wl_signal_add(&xwayland->shell_v1->events.new_surface,
|
wl_signal_add(&xwayland->shell_v1->events.new_surface,
|
||||||
&xwm->shell_v1_new_surface);
|
&xwm->shell_v1_new_surface);
|
||||||
|
xwm->shell_v1_destroy.notify = handle_shell_v1_destroy;
|
||||||
|
wl_signal_add(&xwayland->shell_v1->events.destroy,
|
||||||
|
&xwm->shell_v1_destroy);
|
||||||
|
|
||||||
xwm_create_wm_window(xwm);
|
xwm_create_wm_window(xwm);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue