mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-08 07:48:07 +02:00
xdg-shell: fix weston crash while send configuration
When xdg_toplevel_send_configure is executed, the xdg_toplevel resource may have already been destroyed, causing Weston to crash. Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
This commit is contained in:
parent
df8af39a2a
commit
4e4d7993ba
1 changed files with 25 additions and 0 deletions
|
|
@ -1118,12 +1118,34 @@ static const struct xdg_popup_interface weston_desktop_xdg_popup_implementation
|
|||
.reposition = weston_desktop_xdg_popup_protocol_reposition,
|
||||
};
|
||||
|
||||
static bool
|
||||
weston_destop_xdg_surface_resource_available(struct weston_desktop_xdg_surface *surface)
|
||||
{
|
||||
bool resource_available = false;
|
||||
|
||||
switch (surface->role) {
|
||||
case WESTON_DESKTOP_XDG_SURFACE_ROLE_NONE:
|
||||
break;
|
||||
case WESTON_DESKTOP_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||
resource_available = !!((struct weston_desktop_xdg_toplevel *) surface)->resource;
|
||||
break;
|
||||
case WESTON_DESKTOP_XDG_SURFACE_ROLE_POPUP:
|
||||
resource_available = !!((struct weston_desktop_xdg_popup *) surface)->resource;
|
||||
break;
|
||||
}
|
||||
|
||||
return resource_available;
|
||||
}
|
||||
|
||||
static void
|
||||
weston_desktop_xdg_surface_send_configure(void *user_data)
|
||||
{
|
||||
struct weston_desktop_xdg_surface *surface = user_data;
|
||||
struct weston_desktop_xdg_surface_configure *configure;
|
||||
|
||||
if (!weston_destop_xdg_surface_resource_available(surface))
|
||||
return;
|
||||
|
||||
surface->configure_idle = NULL;
|
||||
|
||||
configure = zalloc(weston_desktop_surface_configure_biggest_size);
|
||||
|
|
@ -1504,6 +1526,9 @@ weston_desktop_xdg_surface_committed(struct weston_desktop_surface *dsurface,
|
|||
struct weston_surface *wsurface =
|
||||
weston_desktop_surface_get_surface (dsurface);
|
||||
|
||||
if (!weston_destop_xdg_surface_resource_available(surface))
|
||||
return;
|
||||
|
||||
if (weston_surface_has_content(wsurface) && !surface->configured) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue