[Spice-devel] [spice-gtk] usb: Remove device from ::devices before emitting device-removed
Marc-André Lureau
mlureau at redhat.com
Tue Mar 5 04:09:35 PST 2013
ack
----- Original Message -----
> 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.
> ---
> gtk/usb-device-manager.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> 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,
> --
> 1.8.1.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list