[gtk/gtk-3-24: 2/3] gdk/x11: Properly unref removed device in XI2 device manager



commit 9ce66b9d059e3552ca6feea171aa8541fc1a5cb3
Author: Sebastian Keller <skeller gnome org>
Date:   Mon Jan 27 01:02:29 2020 +0100

    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/1359

 gdk/x11/gdkdevicemanager-xi2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 135a0512aa..00e64d2a84 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -643,14 +643,14 @@ remove_device (GdkX11DeviceManagerXI2 *device_manager,
   if (device)
     {
       detach_from_seat (device);
-      device_manager->devices = g_list_remove (device_manager->devices, device);
-
-      g_signal_emit_by_name (device_manager, "device-removed", 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_signal_emit_by_name (device_manager, "device-removed", device);
+      g_object_run_dispose (G_OBJECT (device));
+      g_object_unref (device);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]