summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Danis <frederic.danis@collabora.com>2023-01-19 17:54:12 +0100
committerRichard Hughes <richard@hughsie.com>2023-01-19 17:17:13 +0000
commit8ba58a2e440acc485ca2ea7003f259376336d36e (patch)
tree33cda311815c64a0a458fcf51084c6aa6fb187be
parent8fa1305a46a1e8403dfdabd56be9fdad5fa65161 (diff)
downloadgusb-8ba58a2e440acc485ca2ea7003f259376336d36e.tar.gz
Save removed devices in JSON dump only when requested
Removed devices should not be saved when trying dump events per update phase.
-rw-r--r--gusb/gusb-context.c10
-rw-r--r--gusb/gusb-context.h1
2 files changed, 7 insertions, 4 deletions
diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c
index 6e8d82f..f6a52c8 100644
--- a/gusb/gusb-context.c
+++ b/gusb/gusb-context.c
@@ -486,10 +486,12 @@ g_usb_context_save_with_tag(GUsbContext *self,
/* array of devices */
json_builder_set_member_name(json_builder, "UsbDevices");
json_builder_begin_array(json_builder);
- for (guint i = 0; i < priv->devices_removed->len; i++) {
- GUsbDevice *device = g_ptr_array_index(priv->devices_removed, i);
- if (!_g_usb_device_save(device, json_builder, error))
- return FALSE;
+ if (priv->flags & G_USB_CONTEXT_FLAGS_SAVE_REMOVED_DEVICES) {
+ for (guint i = 0; i < priv->devices_removed->len; i++) {
+ GUsbDevice *device = g_ptr_array_index(priv->devices_removed, i);
+ if (!_g_usb_device_save(device, json_builder, error))
+ return FALSE;
+ }
}
for (guint i = 0; i < priv->devices->len; i++) {
GUsbDevice *device = g_ptr_array_index(priv->devices, i);
diff --git a/gusb/gusb-context.h b/gusb/gusb-context.h
index f633520..b1542da 100644
--- a/gusb/gusb-context.h
+++ b/gusb/gusb-context.h
@@ -41,6 +41,7 @@ typedef enum {
G_USB_CONTEXT_FLAGS_NONE = 0,
G_USB_CONTEXT_FLAGS_AUTO_OPEN_DEVICES = 1 << 0,
G_USB_CONTEXT_FLAGS_SAVE_EVENTS = 1 << 1,
+ G_USB_CONTEXT_FLAGS_SAVE_REMOVED_DEVICES = 1 << 2,
/*< private >*/
G_USB_CONTEXT_FLAGS_LAST
} GUsbContextFlags;