[gnome-settings-daemon] device-manager: fix storing/releasing of gdk_devices



commit 1ea20ae6b7af7698ce19239b14f9a0ae1339a6be
Author: Benjamin Tissoires <benjamin tissoires redhat com>
Date:   Fri Mar 13 20:08:30 2015 -0400

    device-manager: fix storing/releasing of gdk_devices
    
    When emitting the signals "device-added" and "device-removed", the
    other plugins connected might want to look at the devices stored
    in the manager->gdk_devices hashtable.
    
    That is actually the case for wacom devices.
    Changing the order of storing/releasing the device and emitting the signals
    makes everybody happy.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746112

 plugins/common/gsd-device-manager-x11.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/plugins/common/gsd-device-manager-x11.c b/plugins/common/gsd-device-manager-x11.c
index 89397bd..cee7b2f 100644
--- a/plugins/common/gsd-device-manager-x11.c
+++ b/plugins/common/gsd-device-manager-x11.c
@@ -109,14 +109,14 @@ add_device (GsdX11DeviceManager *manager,
        if (!device_file)
                return;
 
+       /* Takes ownership of device_file */
+       g_hash_table_insert (manager->gdk_devices, gdk_device, device_file);
+
        if (!g_hash_table_lookup (manager->devices, device_file)) {
                device = create_device (gdk_device, device_file);
                g_hash_table_insert (manager->devices, g_strdup (device_file), device);
                g_signal_emit_by_name (manager, "device-added", device);
        }
-
-       /* Takes ownership of device_file */
-       g_hash_table_insert (manager->gdk_devices, gdk_device, device_file);
 }
 
 static void
@@ -136,13 +136,13 @@ remove_device (GsdX11DeviceManager *manager,
        if (device)
                g_object_ref (device);
 
-       g_hash_table_remove (manager->devices, device_file);
-       g_hash_table_remove (manager->gdk_devices, gdk_device);
-
        if (device) {
                g_signal_emit_by_name (manager, "device-removed", device);
                g_object_unref (device);
        }
+
+       g_hash_table_remove (manager->devices, device_file);
+       g_hash_table_remove (manager->gdk_devices, gdk_device);
 }
 
 static void


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