aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2022-02-11 09:06:26 -0500
committerKirill Primak <vyivel@eclair.cafe>2022-02-21 17:11:32 +0000
commit130c3bcf6361a76a889790e1907b78c607053659 (patch)
tree0236adf69ab75a6b36ea7509f1e59bf31a479e54
parentfd80329c53ed00b9411095b60e9d0611c016ec03 (diff)
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.
-rw-r--r--include/wlr/interfaces/wlr_input_device.h6
-rw-r--r--types/wlr_input_device.c18
2 files changed, 12 insertions, 12 deletions
diff --git a/include/wlr/interfaces/wlr_input_device.h b/include/wlr/interfaces/wlr_input_device.h
index de527393..ab314807 100644
--- a/include/wlr/interfaces/wlr_input_device.h
+++ b/include/wlr/interfaces/wlr_input_device.h
@@ -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);
+/**
+ * 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);
#endif
diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c
index 50afdaff..8056556b 100644
--- a/types/wlr_input_device.c
+++ b/types/wlr_input_device.c
@@ -41,8 +41,6 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
return;
}
- wlr_signal_emit_safe(&dev->events.destroy, dev);
-
if (dev->_device) {
switch (dev->type) {
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:
wlr_tablet_pad_destroy(dev->tablet_pad);
break;
- default:
- wlr_log(WLR_DEBUG, "Warning: leaking memory %p %p %d",
- dev->_device, dev, dev->type);
- break;
}
- }
- free(dev->name);
- free(dev->output_name);
- if (dev->impl && dev->impl->destroy) {
- dev->impl->destroy(dev);
} else {
- free(dev);
+ wlr_input_device_finish(dev);
+ if (dev->impl && dev->impl->destroy) {
+ dev->impl->destroy(dev);
+ } else {
+ free(dev);
+ }
}
}