libweston: Make weston_touch destruction safe
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@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
7a314d6328
commit
b0b598c73c
+12
-2
@@ -1199,8 +1199,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);
|
||||
@@ -2574,7 +2584,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
|
||||
|
||||
Reference in New Issue
Block a user