[PATCH weston 3/8] libweston: Make weston_touch destruction safe
Pekka Paalanen
ppaalanen at gmail.com
Wed Jan 31 11:56:28 UTC 2018
On Fri, 26 Jan 2018 18:47:57 +0200
Alexandros Frantzis <alexandros.frantzis at collabora.com> wrote:
> Ensure the server can safely handle client requests for wl_touch
> resources that have become inert due to a weston_touch object
> destruction.
>
> This change involves, among other things, setting the weston_touch
> object, instead of the weston_seat object, as the user data for wl_touch
> resources. Although this is not strictly required at the moment (since
> no code is using the wl_touch user data), it makes the code safer:
>
> * It makes more sense conceptually.
> * It is consistent with how wl_pointer resources are handled.
> * It allows us to clear the user data during weston_touch
> destruction, so other code can check whether the resource is
> inert.
>
> Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
> ---
> libweston/input.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/libweston/input.c b/libweston/input.c
> index 96cabf25..48bcc55c 100644
> --- a/libweston/input.c
> +++ b/libweston/input.c
> @@ -1221,8 +1221,18 @@ weston_touch_create(void)
> WL_EXPORT void
> weston_touch_destroy(struct weston_touch *touch)
> {
> - /* XXX: What about touch->resource_list? */
> + struct wl_resource *resource;
> +
> + wl_resource_for_each(resource, &touch->resource_list) {
> + wl_resource_set_user_data(resource, NULL);
> + }
> +
> + wl_resource_for_each(resource, &touch->focus_resource_list) {
> + wl_resource_set_user_data(resource, NULL);
> + }
>
> + wl_list_remove(&touch->resource_list);
> + wl_list_remove(&touch->focus_resource_list);
> wl_list_remove(&touch->focus_view_listener.link);
> wl_list_remove(&touch->focus_resource_listener.link);
> free(touch);
> @@ -2599,7 +2609,7 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource,
> wl_resource_get_link(cr));
> }
> wl_resource_set_implementation(cr, &touch_interface,
> - seat, unbind_resource);
> + touch, unbind_resource);
> }
>
> static void
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180131/24e0d276/attachment.sig>
More information about the wayland-devel
mailing list