summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-03-11 09:49:47 +0000
committerRichard Hughes <richard@hughsie.com>2016-03-11 09:49:47 +0000
commitbafb554b74f948bf24e780a46e0258ddad366cdf (patch)
treecb5e6af07873ff96407883db78ccd5b25e435465
parent24be58187a5e6cb9a85b529aa5d5170757bc8b68 (diff)
downloadgusb-bafb554b74f948bf24e780a46e0258ddad366cdf.tar.gz
trivial: Return the replugged device when using g_usb_context_get_devices()
-rw-r--r--gusb/gusb-context.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index eaad2c9..4fb3100 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -324,6 +324,9 @@ g_usb_context_add_device (GUsbContext *context,
goto out;
}
+ /* add to enumerated list */
+ g_ptr_array_add (priv->devices, g_object_ref (device));
+
/* if we're waiting for replug, suppress the signal */
platform_id = g_usb_device_get_platform_id (device);
replug_helper = g_hash_table_lookup (priv->dict_replug, platform_id);
@@ -335,7 +338,7 @@ g_usb_context_add_device (GUsbContext *context,
goto out;
}
- g_ptr_array_add (priv->devices, g_object_ref (device));
+ /* emit signal */
g_usb_context_emit_device_add (context, device);
out:
if (device != NULL)
@@ -362,6 +365,9 @@ g_usb_context_remove_device (GUsbContext *context,
return;
}
+ /* remove from enumerated list */
+ g_ptr_array_remove (priv->devices, device);
+
/* if we're waiting for replug, suppress the signal */
platform_id = g_usb_device_get_platform_id (device);
replug_helper = g_hash_table_lookup (priv->dict_replug, platform_id);
@@ -370,8 +376,8 @@ g_usb_context_remove_device (GUsbContext *context,
goto out;
}
+ /* emit signal */
g_usb_context_emit_device_remove (context, device);
- g_ptr_array_remove (priv->devices, device);
out:
g_object_unref (device);
}
@@ -1045,7 +1051,6 @@ g_usb_context_wait_for_replug (GUsbContext *context,
/* so we timed out; emit the removal now */
if (replug_helper->timeout_id == 0) {
g_usb_context_emit_device_remove (context, replug_helper->device);
- g_ptr_array_remove (priv->devices, replug_helper->device);
g_set_error_literal (error,
G_USB_CONTEXT_ERROR,
G_USB_CONTEXT_ERROR_INTERNAL,