[Spice-devel] [PATCH v6 13/14] UsbDeviceWidget: Use asynchronous disconnect API
Dmitry Fleytman
dmitry at daynix.com
Tue Mar 8 13:45:33 UTC 2016
> On 1 Mar 2016, at 22:17 PM, Jonathon Jongsma <jjongsma at redhat.com> wrote:
>
> On Sun, 2016-02-28 at 11:54 +0200, Dmitry Fleytman wrote:
>> From: Kirill Moizik <kmoizik at redhat.com>
>>
>> Signed-off-by: Kirill Moizik <kmoizik at redhat.com>
>> Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
>> ---
>> src/usb-device-widget.c | 33 ++++++++++++++++++++++++---------
>> 1 file changed, 24 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
>> index 56bdeaf..3166225 100644
>> --- a/src/usb-device-widget.c
>> +++ b/src/usb-device-widget.c
>> @@ -436,6 +436,20 @@ typedef struct _connect_cb_data {
>> SpiceUsbDeviceWidget *self;
>> } connect_cb_data;
>>
>> +static void connect_cb_data_free(connect_cb_data *data)
>> +{
>> + spice_usb_device_widget_update_status(data->self);
>> + g_object_unref(data->check);
>> + g_object_unref(data->self);
>> + g_free(data);
>> +}
>> +
>> +static void _disconnect_cb(GObject *gobject, GAsyncResult *res, gpointer
>> user_data)
>> +{
>> + connect_cb_data *data = user_data;
>> + connect_cb_data_free(data);
>> +}
>
> As mentioned in an earlier patch, there really should be a
> _disconnect_device_finish() function to call here. Otherwise the patch looks
> good.
Done, thanks.
>
>> +
>> static void connect_cb(GObject *gobject, GAsyncResult *res, gpointer
>> user_data)
>> {
>> SpiceUsbDeviceManager *manager = SPICE_USB_DEVICE_MANAGER(gobject);
>> @@ -461,10 +475,7 @@ static void connect_cb(GObject *gobject, GAsyncResult
>> *res, gpointer user_data)
>> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->check), FALSE);
>> }
>>
>> - spice_usb_device_widget_update_status(self);
>> - g_object_unref(data->check);
>> - g_object_unref(data->self);
>> - g_free(data);
>> + connect_cb_data_free(data);
>> }
>>
>> static void checkbox_clicked_cb(GtkWidget *check, gpointer user_data)
>> @@ -474,19 +485,23 @@ static void checkbox_clicked_cb(GtkWidget *check,
>> gpointer user_data)
>> SpiceUsbDevice *device;
>>
>> device = g_object_get_data(G_OBJECT(check), "usb-device");
>> + connect_cb_data *data = g_new(connect_cb_data, 1);
>> + data->check = g_object_ref(check);
>> + data->self = g_object_ref(self);
>>
>> if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
>> - connect_cb_data *data = g_new(connect_cb_data, 1);
>> - data->check = g_object_ref(check);
>> - data->self = g_object_ref(self);
>> spice_usb_device_manager_connect_device_async(priv->manager,
>> device,
>> NULL,
>> connect_cb,
>> data);
>> } else {
>> - spice_usb_device_manager_disconnect_device(priv->manager,
>> - device);
>> + spice_usb_device_manager_disconnect_device_async(priv->manager,
>> + device,
>> + NULL,
>> + _disconnect_cb,
>> + data);
>> +
>> }
>> spice_usb_device_widget_update_status(self);
>> }
>
>
> Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com <mailto:jjongsma at redhat.com>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160308/3bafc048/attachment-0001.html>
More information about the Spice-devel
mailing list