backend/wayland: fix input creation error handling

This commit is contained in:
Mykola Orliuk 2020-10-18 19:12:01 +02:00 committed by Simon Ser
parent 41bf1c6871
commit 009cd634a2

View file

@ -636,9 +636,6 @@ void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *outp
pointer->wl_pointer = wl_pointer; pointer->wl_pointer = wl_pointer;
pointer->output = output; pointer->output = output;
wl_signal_add(&output->wlr_output.events.destroy, &pointer->output_destroy);
pointer->output_destroy.notify = pointer_handle_output_destroy;
struct wlr_wl_input_device *dev = struct wlr_wl_input_device *dev =
create_wl_input_device(backend, WLR_INPUT_DEVICE_POINTER); create_wl_input_device(backend, WLR_INPUT_DEVICE_POINTER);
if (dev == NULL) { if (dev == NULL) {
@ -648,6 +645,9 @@ void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *outp
} }
pointer->input_device = dev; pointer->input_device = dev;
wl_signal_add(&output->wlr_output.events.destroy, &pointer->output_destroy);
pointer->output_destroy.notify = pointer_handle_output_destroy;
wlr_dev = &dev->wlr_input_device; wlr_dev = &dev->wlr_input_device;
wlr_dev->pointer = &pointer->wlr_pointer; wlr_dev->pointer = &pointer->wlr_pointer;
wlr_dev->output_name = strdup(output->wlr_output.name); wlr_dev->output_name = strdup(output->wlr_output.name);
@ -686,7 +686,7 @@ void create_wl_keyboard(struct wl_keyboard *wl_keyboard, struct wlr_wl_backend *
wlr_dev->keyboard = calloc(1, sizeof(*wlr_dev->keyboard)); wlr_dev->keyboard = calloc(1, sizeof(*wlr_dev->keyboard));
if (!wlr_dev->keyboard) { if (!wlr_dev->keyboard) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
free(dev); wlr_input_device_destroy(wlr_dev);
return; return;
} }
wlr_keyboard_init(wlr_dev->keyboard, NULL); wlr_keyboard_init(wlr_dev->keyboard, NULL);
@ -707,7 +707,7 @@ void create_wl_touch(struct wl_touch *wl_touch, struct wlr_wl_backend *wl) {
wlr_dev->touch = calloc(1, sizeof(*wlr_dev->touch)); wlr_dev->touch = calloc(1, sizeof(*wlr_dev->touch));
if (!wlr_dev->touch) { if (!wlr_dev->touch) {
wlr_log_errno(WLR_ERROR, "Allocation failed"); wlr_log_errno(WLR_ERROR, "Allocation failed");
free(dev); wlr_input_device_destroy(wlr_dev);
return; return;
} }
wlr_touch_init(wlr_dev->touch, NULL); wlr_touch_init(wlr_dev->touch, NULL);