mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
types/wlr_input_device: call the specialized input device destroy function on destroy
In case the `wlr_input_device` is not owned by a specialized input device, the function will finish the wlr_input_device and call it's implementation destroy function if an implementation has been supplied, or simply free it.
This commit is contained in:
parent
fd80329c53
commit
130c3bcf63
2 changed files with 13 additions and 13 deletions
|
@ -25,6 +25,12 @@ void wlr_input_device_init(struct wlr_input_device *wlr_device,
|
||||||
*/
|
*/
|
||||||
void wlr_input_device_finish(struct wlr_input_device *wlr_device);
|
void wlr_input_device_finish(struct wlr_input_device *wlr_device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the specialized input device destroy function.
|
||||||
|
* If the wlr_input_device is not owned by a specialized input device, the
|
||||||
|
* function will finish the wlr_input_device, and either call its implementation
|
||||||
|
* destroy function if one has been given, or free the wlr_input_device.
|
||||||
|
*/
|
||||||
void wlr_input_device_destroy(struct wlr_input_device *dev);
|
void wlr_input_device_destroy(struct wlr_input_device *dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,8 +41,6 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_signal_emit_safe(&dev->events.destroy, dev);
|
|
||||||
|
|
||||||
if (dev->_device) {
|
if (dev->_device) {
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||||
|
@ -63,17 +61,13 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
||||||
case WLR_INPUT_DEVICE_TABLET_PAD:
|
case WLR_INPUT_DEVICE_TABLET_PAD:
|
||||||
wlr_tablet_pad_destroy(dev->tablet_pad);
|
wlr_tablet_pad_destroy(dev->tablet_pad);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
wlr_log(WLR_DEBUG, "Warning: leaking memory %p %p %d",
|
} else {
|
||||||
dev->_device, dev, dev->type);
|
wlr_input_device_finish(dev);
|
||||||
break;
|
if (dev->impl && dev->impl->destroy) {
|
||||||
|
dev->impl->destroy(dev);
|
||||||
|
} else {
|
||||||
|
free(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(dev->name);
|
|
||||||
free(dev->output_name);
|
|
||||||
if (dev->impl && dev->impl->destroy) {
|
|
||||||
dev->impl->destroy(dev);
|
|
||||||
} else {
|
|
||||||
free(dev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue