wayland: do not leak shortcut inhibit data

We would free the shortcut inhibit data only when the client destroys
its request, which is not the case when the clients itself is
destroyed, leading to a leak of the shortcut inhibit data.

Free the data on resource destruction instead, and simply destroy the
resource on destroy request.

https://bugzilla.gnome.org/show_bug.cgi?id=787568
This commit is contained in:
Olivier Fourdan 2017-09-12 10:27:32 +02:00
parent 9c16e4e2f3
commit 2bf7974076

View File

@ -41,8 +41,7 @@ struct _MetaWaylandKeyboardShotscutsInhibit
}; };
static void static void
zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client, zwp_keyboard_shortcuts_inhibit_destructor (struct wl_resource *resource)
struct wl_resource *resource)
{ {
MetaWaylandKeyboardShotscutsInhibit *shortcut_inhibit; MetaWaylandKeyboardShotscutsInhibit *shortcut_inhibit;
@ -64,6 +63,12 @@ zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
shortcut_inhibit->seat); shortcut_inhibit->seat);
} }
g_free (shortcut_inhibit); g_free (shortcut_inhibit);
}
static void
zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
struct wl_resource *resource)
{
wl_resource_destroy (resource); wl_resource_destroy (resource);
} }
@ -148,7 +153,7 @@ zwp_keyboard_shortcuts_inhibit_manager_inhibit_shortcuts (struct wl_client *cl
wl_resource_set_implementation (keyboard_shortcuts_inhibit_resource, wl_resource_set_implementation (keyboard_shortcuts_inhibit_resource,
&meta_keyboard_shortcuts_inhibit_interface, &meta_keyboard_shortcuts_inhibit_interface,
shortcut_inhibit, shortcut_inhibit,
NULL); zwp_keyboard_shortcuts_inhibit_destructor);
} }
static const struct zwp_keyboard_shortcuts_inhibit_manager_v1_interface static const struct zwp_keyboard_shortcuts_inhibit_manager_v1_interface