diff options
author | Richard Hughes <richard@hughsie.com> | 2022-09-13 10:39:44 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2022-09-13 10:51:25 +0100 |
commit | fa4b7038b3828e5f9cb3bc8f67f2220990a09f77 (patch) | |
tree | bd71615cb0210d95c7471d10edbfab031da0df1c | |
parent | 1470f58a411a290af39cc409573a9ff0d765ad85 (diff) | |
download | gusb-fa4b7038b3828e5f9cb3bc8f67f2220990a09f77.tar.gz |
trivial: Remove existing devices when loading a context
-rw-r--r-- | gusb/gusb-context.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c index d8be8c4..b0a3b99 100644 --- a/gusb/gusb-context.c +++ b/gusb/gusb-context.c @@ -384,6 +384,10 @@ g_usb_context_load(GUsbContext *self, JsonObject *json_object, GError **error) g_return_val_if_fail(json_object != NULL, FALSE); g_return_val_if_fail(error == NULL || *error == NULL, -1); + /* remove existing devices */ + g_ptr_array_set_size(priv->devices, 0); + g_ptr_array_set_size(priv->devices_removed, 0); + if (!json_object_has_member(json_object, "UsbDevices")) { g_set_error_literal(error, G_IO_ERROR, |