mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-27 11:40:11 +01:00
libweston: fix crash when a client queries a destroyed output
A client can call get_xdg_output() at any time. If the output was destroyed, then all output resources are orphaned. This includes clearing the user data of the resource. This can happen, for example, when a monitor or HDMI switch quickly toggles the HDMI hotplug pin. So check if a head is associated with the resource. If not, just create the resource and then return immediately. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
parent
67253b30e8
commit
3866ecc5d3
1 changed files with 12 additions and 1 deletions
|
|
@ -8762,7 +8762,7 @@ xdg_output_manager_get_xdg_output(struct wl_client *client,
|
|||
{
|
||||
int version = wl_resource_get_version(manager);
|
||||
struct weston_head *head = wl_resource_get_user_data(output_resource);
|
||||
struct weston_output *output = head->output;
|
||||
struct weston_output *output;
|
||||
struct wl_resource *resource;
|
||||
|
||||
resource = wl_resource_create(client, &zxdg_output_v1_interface,
|
||||
|
|
@ -8772,12 +8772,23 @@ xdg_output_manager_get_xdg_output(struct wl_client *client,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!head) {
|
||||
/* No destroy callback, because the resource is not added to the
|
||||
* heads resource list
|
||||
*/
|
||||
wl_resource_set_implementation(resource, &xdg_output_interface,
|
||||
NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_insert(&head->xdg_output_resource_list,
|
||||
wl_resource_get_link(resource));
|
||||
|
||||
wl_resource_set_implementation(resource, &xdg_output_interface,
|
||||
NULL, xdg_output_unlist);
|
||||
|
||||
output = head->output;
|
||||
|
||||
zxdg_output_v1_send_logical_position(resource,
|
||||
output->pos.c.x,
|
||||
output->pos.c.y);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue