]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: remove tablet/pad signal listeners on destroy
authorJens Peters <jp7677@gmail.com>
Thu, 11 Apr 2024 21:47:10 +0000 (23:47 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 19 May 2024 20:21:52 +0000 (21:21 +0100)
We should remove those when destroying a tablet
or a tablet pad.

Also rename 'tablet' to 'pad' in 'tablet_pad' for better
readability and consistency.

src/input/tablet.c
src/input/tablet_pad.c

index b4a18334f01d4db332881e792b2646fa3ad87c87..e795cdae75677018e9b3e9143d0fd98a05d10cd0 100644 (file)
@@ -124,6 +124,11 @@ handle_destroy(struct wl_listener *listener, void *data)
 {
        struct drawing_tablet *tablet =
                wl_container_of(listener, tablet, handlers.destroy);
+
+       wl_list_remove(&tablet->handlers.tip.link);
+       wl_list_remove(&tablet->handlers.button.link);
+       wl_list_remove(&tablet->handlers.axis.link);
+       wl_list_remove(&tablet->handlers.destroy.link);
        free(tablet);
 }
 
index 29cde1e4396fdf5a1fd7080b17b5d0ccd6d813da..5c7c74f1aef6c3dd75b9078a9015c8a24c9335cd 100644 (file)
@@ -27,19 +27,22 @@ handle_button(struct wl_listener *listener, void *data)
 static void
 handle_destroy(struct wl_listener *listener, void *data)
 {
-       struct drawing_tablet_pad *tablet =
-               wl_container_of(listener, tablet, handlers.destroy);
-       free(tablet);
+       struct drawing_tablet_pad *pad =
+               wl_container_of(listener, pad, handlers.destroy);
+
+       wl_list_remove(&pad->handlers.button.link);
+       wl_list_remove(&pad->handlers.destroy.link);
+       free(pad);
 }
 
 void
 tablet_pad_init(struct seat *seat, struct wlr_input_device *wlr_device)
 {
        wlr_log(WLR_DEBUG, "setting up tablet pad");
-       struct drawing_tablet_pad *tablet = znew(*tablet);
-       tablet->seat = seat;
-       tablet->tablet = wlr_tablet_pad_from_input_device(wlr_device);
-       tablet->tablet->data = tablet;
-       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, button);
-       CONNECT_SIGNAL(wlr_device, &tablet->handlers, destroy);
+       struct drawing_tablet_pad *pad = znew(*pad);
+       pad->seat = seat;
+       pad->tablet = wlr_tablet_pad_from_input_device(wlr_device);
+       pad->tablet->data = pad;
+       CONNECT_SIGNAL(pad->tablet, &pad->handlers, button);
+       CONNECT_SIGNAL(wlr_device, &pad->handlers, destroy);
 }