[Spice-devel] [PATCH shared-cd v1 6/9] Auto-remove shared CD devices on disconnect in usb-device-widget
alexander at daynix.com
alexander at daynix.com
Sun Dec 8 14:03:16 UTC 2019
From: Alexander Nezhinsky <anezhins at redhat.com>
Signed-off-by: Alexander Nezhinsky <anezhins at redhat.com>
---
src/usb-device-widget.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 26c0db0..922108d 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -518,10 +518,27 @@ static void _disconnect_cb(GObject *gobject, GAsyncResult *res, gpointer user_da
{
SpiceUsbDeviceManager *manager = SPICE_USB_DEVICE_MANAGER(gobject);
connect_cb_data *data = user_data;
+ SpiceUsbDevice *device = g_object_get_data(G_OBJECT(data->check), "usb-device");
GError *err = NULL;
+ gboolean rc;
spice_usb_device_manager_disconnect_device_finish(manager, res, &err);
- if (err) {
+ if (!err) {
+ if (spice_usb_device_manager_is_device_shared_cd(manager, device)) {
+ rc = spice_usb_device_manager_remove_shared_cd_device(manager, device, &err);
+ if (!rc) {
+ if (err) {
+ SPICE_DEBUG("Failed to remove %s, %s",
+ gtk_button_get_label(GTK_BUTTON(data->check)),
+ err->message);
+ g_error_free(err);
+ } else {
+ SPICE_DEBUG("Failed to remove %s",
+ gtk_button_get_label(GTK_BUTTON(data->check)));
+ }
+ }
+ }
+ } else {
SPICE_DEBUG("Device disconnection failed");
g_error_free(err);
}
--
2.20.1
More information about the Spice-devel
mailing list