wlr_keyboard_group: fix leak of wlr_keyboard_group->keys

If the underlying wlr_keyboard emits duplicated key-presses,
wlr_keyboard_group->keys might not be empty even after calling
wlr_keyboard_group_remove_keyboard() for all of the keyboards.
This commit is contained in:
tokyo4j 2025-02-15 16:47:52 +09:00
parent bd8454d3bc
commit 86976870bd

View file

@ -306,10 +306,19 @@ void wlr_keyboard_group_remove_keyboard(struct wlr_keyboard_group *group,
}
void wlr_keyboard_group_destroy(struct wlr_keyboard_group *group) {
struct keyboard_group_device *device, *tmp;
wl_list_for_each_safe(device, tmp, &group->devices, link) {
struct keyboard_group_device *device, *tmp_device;
wl_list_for_each_safe(device, tmp_device, &group->devices, link) {
wlr_keyboard_group_remove_keyboard(group, device->keyboard);
}
// Now group->keys might not be empty if a wlr_keyboard has emitted
// duplicated key presses
struct keyboard_group_key *key, *tmp_key;
wl_list_for_each_safe(key, tmp_key, &group->keys, link) {
wl_list_remove(&key->link);
free(key);
}
wlr_keyboard_finish(&group->keyboard);
assert(wl_list_empty(&group->events.enter.listener_list));