[Spice-devel] [spice-gtk Win32 v2 PATCH 5/5] Windows mingw: usb: Comment out some memory cleanups not working on Windows
Uri Lublin
uril at redhat.com
Sun May 20 09:34:12 PDT 2012
It's not nice, but better than crashing.
---
gtk/usb-device-manager.c | 15 +++++++++++++++
gtk/usbutil.c | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index c373447..492689f 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -144,9 +144,14 @@ static void spice_usb_device_manager_init(SpiceUsbDeviceManager *self)
priv->channels = g_ptr_array_new();
#ifdef USE_USBREDIR
+#ifdef WIN32
+ /* FIXME WIN32 use g_ptr_array_new_with_free_func */
+ priv->devices = g_ptr_array_new();
+#else
priv->devices = g_ptr_array_new_with_free_func((GDestroyNotify)
libusb_unref_device);
#endif
+#endif
}
static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
@@ -207,6 +212,8 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
g_signal_connect(G_OBJECT(priv->udev), "uevent",
G_CALLBACK(spice_usb_device_manager_uevent_cb), self);
+/* FIXME: fix coldplug for WIN32 */
+#ifndef WIN32
/* Do coldplug (detection of already connected devices) */
libusb_get_device_list(priv->context, &priv->coldplug_list);
list = g_udev_client_query_by_subsystem(priv->udev, "usb");
@@ -217,6 +224,7 @@ static gboolean spice_usb_device_manager_initable_init(GInitable *initable,
g_list_free(list);
libusb_free_device_list(priv->coldplug_list, 1);
priv->coldplug_list = NULL;
+#endif
return TRUE;
#else
@@ -236,6 +244,7 @@ static void spice_usb_device_manager_finalize(GObject *gobject)
g_ptr_array_unref(priv->devices);
#ifdef USE_USBREDIR
+/* FIXME: verify WIN32 cleanup*/
g_clear_object(&priv->udev);
if (priv->context)
libusb_exit(priv->context);
@@ -830,8 +839,14 @@ GPtrArray* spice_usb_device_manager_get_devices(SpiceUsbDeviceManager *self)
SpiceUsbDeviceManagerPrivate *priv = self->priv;
guint i;
+#ifdef G_OS_WIN32
+ /* FIXME WIN32 use g_ptr_array_new_with_free_func */
+ devices_copy = g_ptr_array_new();
+#else
devices_copy = g_ptr_array_new_with_free_func((GDestroyNotify)
libusb_unref_device);
+#endif
+
for (i = 0; i < priv->devices->len; i++) {
libusb_device *device = g_ptr_array_index(priv->devices, i);
g_ptr_array_add(devices_copy, libusb_ref_device(device));
diff --git a/gtk/usbutil.c b/gtk/usbutil.c
index 704f973..fd3d2de 100644
--- a/gtk/usbutil.c
+++ b/gtk/usbutil.c
@@ -233,6 +233,7 @@ void spice_usb_util_get_device_strings(int bus, int address,
*manufacturer = NULL;
*product = NULL;
+/* FIXME: add windows support for "manufacturer" & "product" */
#if __linux__
*manufacturer = spice_usbutil_get_sysfs_attribute(bus, address, "manufacturer");
*product = spice_usbutil_get_sysfs_attribute(bus, address, "product");
--
1.7.7.6
More information about the Spice-devel
mailing list