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 <erkai.ji@nxp.com>
Signed-off-by: Wujian Sun <wujian.sun_1@nxp.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Wujian Sun 2024-01-26 16:24:31 +08:00
parent 31a9a4831f
commit 042d02f422

View file

@ -892,6 +892,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);
}
}