[Spice-devel] [PATCH 7/9] remove shared CD device on connect-fail during USB redirect attempt
alexander at daynix.com
alexander at daynix.com
Thu Dec 5 17:49:13 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 a772ae0..724b7b5 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -557,6 +557,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) {
@@ -568,7 +569,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),
@@ -576,6 +577,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