[Spice-commits] gtk/usb-device-manager.c

Christophe Fergau teuf at kemper.freedesktop.org
Tue Mar 5 07:42:37 PST 2013


 gtk/usb-device-manager.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 09124ecc50f0ecf7bad1384d3c60a22017ff6249
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Mar 5 12:55:59 2013 +0100

    usb: Remove device from ::devices before emitting device-removed
    
    The code is currently removing the USB device that is gone from
    the SpiceUsbDeviceManager::devices array after the device-removed
    signal has been emitted. As signal handlers are called synchronously,
    this means that the list returned by
    spice_usb_device_manager_get_devices() will still contain the
    removed device if it's called from the signal handler.

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 34ff37c..eafed7c 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -786,8 +786,10 @@ static void spice_usb_device_manager_remove_dev(SpiceUsbDeviceManager  *self,
     spice_usb_device_manager_disconnect_device(self, device);
 
     SPICE_DEBUG("device removed %p", device);
-    g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
+    spice_usb_device_ref(device);
     g_ptr_array_remove(priv->devices, device);
+    g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
+    spice_usb_device_unref(device);
 }
 
 static void spice_usb_device_manager_uevent_cb(GUdevClient     *client,
@@ -1170,8 +1172,10 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
              * So remove the device now
              */
             SPICE_DEBUG("libdev does not exist for %p -- removing", device);
-            g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
+            spice_usb_device_ref(device);
             g_ptr_array_remove(priv->devices, device);
+            g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
+            spice_usb_device_unref(device);
 #endif
             g_simple_async_result_set_error(result,
                                             SPICE_CLIENT_ERROR,


More information about the Spice-commits mailing list