[Spice-devel] [PATCH shared-cd v1 7/9] remove shared CD device on connect-fail during USB redirect attempt

alexander at daynix.com alexander at daynix.com
Sun Dec 8 14:03:17 UTC 2019


From: Alexander Nezhinsky <anezhins at redhat.com>

Signed-off-by: Alexander Nezhinsky <anezhins at redhat.com>
---
 src/usb-device-widget.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 922108d..a8219e5 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -556,6 +556,7 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
     SpiceUsbDevice *device;
     GError *err = NULL;
     gchar *desc;
+    gboolean rc;
 
     spice_usb_device_manager_connect_device_finish(manager, res, &err);
     if (err) {
@@ -567,7 +568,7 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
 
         SPICE_DEBUG("%s", err->message);
         g_signal_emit(self, signals[CONNECT_FAILED], 0, device, err);
-        g_error_free(err);
+        g_clear_error(&err);
 
         /* don't trigger a disconnect if connect failed */
         g_signal_handlers_block_by_func(GTK_TOGGLE_BUTTON(data->check),
@@ -575,6 +576,18 @@ static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer user_data)
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->check), FALSE);
         g_signal_handlers_unblock_by_func(GTK_TOGGLE_BUTTON(data->check),
                                         checkbox_clicked_cb, self);
+
+        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", desc, err->message);
+                    g_clear_error(&err);
+                } else {
+                    SPICE_DEBUG("Failed to remove %s", desc);
+                }
+            }
+        }
     }
 
     connect_cb_data_free(data);
-- 
2.20.1



More information about the Spice-devel mailing list