From 818d76649a5855ec96a864575bea7e4b880b13c5 Mon Sep 17 00:00:00 2001 From: Wujian Sun Date: Fri, 26 Jan 2024 16:24:31 +0800 Subject: [PATCH] libweston-desktop: Fix weston crash when lost the shsurf The shell_surface may disappear when keyboard lost focus, then the shsurf will be NULL. Have an ahead check for shsurf before calling the callback in weston_desktop_surface_foreach_child. Fixes #811 Tested-by: Erkai Ji Signed-off-by: Wujian Sun Signed-off-by: Marius Vlad (cherry picked from commit 042d02f42221e4167dc140dbaf26802d5533b285) --- libweston/desktop/surface.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c index 74707f6a6..789612197 100644 --- a/libweston/desktop/surface.c +++ b/libweston/desktop/surface.c @@ -888,6 +888,8 @@ weston_desktop_surface_foreach_child(struct weston_desktop_surface *surface, { struct weston_desktop_surface *child; - wl_list_for_each(child, &surface->children_list, children_link) - callback(child, user_data); + wl_list_for_each(child, &surface->children_list, children_link) { + if (weston_desktop_surface_get_user_data(child)) + callback(child, user_data); + } }