Unref seats and devices in libinput_destroy()
authorJonas Ådahl <jadahl@gmail.com>
Mon, 16 Dec 2013 21:52:05 +0000 (22:52 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Mon, 16 Dec 2013 21:52:05 +0000 (22:52 +0100)
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
src/libinput.c

index ebfb9289af1d29a680d44cb85cf4921c736e6ff4..1019e3cc7015fdd52461ac70ea39954f9d5089dc 100644 (file)
@@ -384,11 +384,22 @@ LIBINPUT_EXPORT void
 libinput_destroy(struct libinput *libinput)
 {
        struct libinput_event *event;
+       struct libinput_device *device, *next_device;
+       struct libinput_seat *seat, *next_seat;
 
        while ((event = libinput_get_event(libinput)))
               free(event);
        free(libinput->events);
 
+       list_for_each_safe(seat, next_seat, &libinput->seat_list, link) {
+               list_for_each_safe(device, next_device,
+                                  &seat->devices_list,
+                                  link)
+                       libinput_device_unref(device);
+
+               libinput_seat_unref(seat);
+       }
+
        close(libinput->epoll_fd);
        free(libinput);
 }