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

Hans de Goede jwrdegoede at kemper.freedesktop.org
Thu Sep 1 08:13:44 PDT 2011


 gtk/spicy.c              |    3 +--
 gtk/usb-device-manager.c |   13 ++++++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 1ef26caa3b5900cca19e809b58b971ccdb0d65d7
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Sep 1 16:35:19 2011 +0200

    spice_usb_device_get_description fixups
    
    1) Fix spice_usb_device_get_description compilation when building without
       usb support
    2) Don't return "Unknown" when the device param is NULL, the caller should
       g_free the returned string, so we cannot return a const string
    3) Fix the existing callers to actually g_free the result of
       spice_usb_device_get_description. To avoid code duplication this patch
       makes usb-device-manager prefix the error it gets from the usbredir-channel,
       so that users of the auto-connect-failed signal can use the error as is.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/gtk/spicy.c b/gtk/spicy.c
index 362ba04..a118ecd 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1544,8 +1544,7 @@ static void auto_connect_failed(SpiceUsbDeviceManager *manager,
                                     GTK_BUTTONS_CLOSE,
                                     "USB redirection error");
     gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
-        "Unable to auto redirect %s: %s",
-        spice_usb_device_get_description(device), error->message);
+                                             "%s", error->message);
     gtk_dialog_run(GTK_DIALOG(dialog));
     gtk_widget_destroy(dialog);
 }
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index ae8296a..b14369a 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -359,8 +359,11 @@ static void spice_usb_device_manager_dev_added(GUsbDeviceList *devlist,
         GError *err = NULL;
         spice_usb_device_manager_connect_device(manager, device, &err);
         if (err) {
-            g_warning("Could not auto-redirect %s: %s",
-                      spice_usb_device_get_description(device), err->message);
+            gchar *desc = spice_usb_device_get_description(device);
+            g_prefix_error(&err, "Could not auto-redirect %s: ", desc);
+            g_free(desc);
+
+            g_warning("%s", err->message);
             g_signal_emit(manager, signals[AUTO_CONNECT_FAILED], 0, device, err);
             g_error_free(err);
         }
@@ -626,13 +629,17 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
  */
 gchar *spice_usb_device_get_description(SpiceUsbDevice *device)
 {
+#ifdef USE_USBREDIR
     /* FIXME, extend gusb to get vid:pid + usb descriptor strings, use those */
     int bus, address;
 
-    g_return_val_if_fail(device != NULL, "Unknown");
+    g_return_val_if_fail(device != NULL, NULL);
 
     bus = g_usb_device_get_bus((GUsbDevice *)device);
     address = g_usb_device_get_address((GUsbDevice *)device);
 
     return g_strdup_printf("USB device at %d-%d", bus, address);
+#else
+    return NULL;
+#endif
 }


More information about the Spice-commits mailing list