From 5040d81e03b8cb5f1f580ba865f78cde2224500d Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Mon, 27 Jan 2020 00:59:56 +0100 Subject: [PATCH 1/2] gdkseatdefault: Unref removed slave devices Adding a slave device adds a ref, but removing it does not unref it. https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358 --- gdk/gdkseatdefault.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdk/gdkseatdefault.c b/gdk/gdkseatdefault.c index 22b4b64e9b..17253f2ac5 100644 --- a/gdk/gdkseatdefault.c +++ b/gdk/gdkseatdefault.c @@ -417,6 +417,7 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat, priv->capabilities |= device_get_capability (GDK_DEVICE (l->data)); gdk_seat_device_removed (GDK_SEAT (seat), device); + g_object_unref (device); } else if (g_list_find (priv->slave_keyboards, device)) { @@ -427,6 +428,7 @@ gdk_seat_default_remove_slave (GdkSeatDefault *seat, priv->capabilities |= device_get_capability (GDK_DEVICE (l->data)); gdk_seat_device_removed (GDK_SEAT (seat), device); + g_object_unref (device); } } From 9c6669be487c29335d25d11f2f50f5f32c203e3b Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Mon, 27 Jan 2020 01:02:29 +0100 Subject: [PATCH 2/2] gdk/x11: Properly unref removed device in XI2 device manager When a device is added, there are two references to it by the device manager, the initial one and the one used for the id_table. Removing a device only removed the reference added by the id_table resulting in the GdkDevice being leaked. https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358 --- gdk/x11/gdkdevicemanager-xi2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index 645e992c38..86bf669c8a 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -685,12 +685,13 @@ remove_device (GdkX11DeviceManagerXI2 *device_manager, if (device) { detach_from_seat (device); - device_manager->devices = g_list_remove (device_manager->devices, device); - - g_object_run_dispose (G_OBJECT (device)); g_hash_table_remove (device_manager->id_table, GINT_TO_POINTER (device_id)); + + device_manager->devices = g_list_remove (device_manager->devices, device); + g_object_run_dispose (G_OBJECT (device)); + g_object_unref (device); } }