[PATCH v3 2/2] weston-info: destroy wl_keyboard

Peter Hutterer peter.hutterer at who-t.net
Mon May 21 03:27:00 UTC 2018


On Mon, Apr 30, 2018 at 11:35:50AM +0200, wl at ongy.net wrote:
> From: Markus Ongyerth <wl at ongy.net>
> 
> Fixes a memory leak by calling wl_keyboard_destroy on a any keyboard

already has my rev-by anyway, but "on a any" seems overly excessive here ;)

Cheers,
   Peter

> that was used to listen for events.
> 
> Signed-off-by: Markus Ongyerth <wl at ongy.net>
> Acked-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  clients/weston-info.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/clients/weston-info.c b/clients/weston-info.c
> index 6606117a..609e270a 100644
> --- a/clients/weston-info.c
> +++ b/clients/weston-info.c
> @@ -118,6 +118,7 @@ struct seat_info {
>  	struct wl_seat *seat;
>  	struct weston_info *info;
>  
> +	struct wl_keyboard *keyboard;
>  	uint32_t capabilities;
>  	char *name;
>  
> @@ -498,10 +499,8 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
>  		return;
>  
>  	if (caps & WL_SEAT_CAPABILITY_KEYBOARD) {
> -		struct wl_keyboard *keyboard;
> -
> -		keyboard = wl_seat_get_keyboard(seat->seat);
> -		wl_keyboard_add_listener(keyboard, &keyboard_listener,
> +		seat->keyboard = wl_seat_get_keyboard(seat->seat);
> +		wl_keyboard_add_listener(seat->keyboard, &keyboard_listener,
>  					 seat);
>  
>  		seat->info->roundtrip_needed = true;
> @@ -531,6 +530,9 @@ destroy_seat_info(void *data)
>  	if (seat->name != NULL)
>  		free(seat->name);
>  
> +	if (seat->keyboard)
> +		wl_keyboard_destroy(seat->keyboard);
> +
>  	wl_list_remove(&seat->global_link);
>  }
>  
> -- 
> 2.17.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list