From d6681cedeec37a541322c9161de504f752176a9b Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 13 Dec 2023 09:58:28 +0100 Subject: [PATCH] ivi-shell: clear seat focus if necessary when a surface is destroyed Otherwise shseat->focused_ivisurf can point to deleted memory. This does not happen with the hmi-controller because it explicitly assigns a new focused surface. But the ivi-shell should not relay on the controller here. Signed-off-by: Michael Olbrich --- ivi-shell/ivi-shell.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c index 4114b5313..17ed7cf89 100644 --- a/ivi-shell/ivi-shell.c +++ b/ivi-shell/ivi-shell.c @@ -220,12 +220,19 @@ ivi_shell_surface_get_label(struct weston_surface *surface, static void layout_surface_cleanup(struct ivi_shell_surface *ivisurf) { + struct weston_seat *seat; assert(ivisurf->layout_surface != NULL); /* destroy weston_surface destroy signal. */ if (!ivisurf->layout_surface->weston_desktop_surface) wl_list_remove(&ivisurf->surface_destroy_listener.link); + wl_list_for_each(seat, &ivisurf->surface->compositor->seat_list, link) { + struct ivi_shell_seat *shseat = get_ivi_shell_seat(seat); + if (shseat->focused_ivisurf == ivisurf->layout_surface) + shseat->focused_ivisurf = NULL; + } + ivi_layout_surface_destroy(ivisurf->layout_surface); ivisurf->layout_surface = NULL;