From: Richard Hughes Date: Mon, 23 Jan 2023 15:54:10 +0000 (+0000) Subject: trivial: Proxy the _SAVE_EVENTS flag even if set at runtime X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ab04bb345c241e2d4150014ec8546f9259957989;p=fwupd.git trivial: Proxy the _SAVE_EVENTS flag even if set at runtime --- diff --git a/src/fu-usb-backend.c b/src/fu-usb-backend.c index 1f1a2f58b..92439c175 100644 --- a/src/fu-usb-backend.c +++ b/src/fu-usb-backend.c @@ -76,6 +76,24 @@ fu_usb_backend_context_finalized_cb(gpointer data, GObject *where_the_object_was g_critical("GUsbContext %p was finalized from under our feet!", where_the_object_was); } +static void +fu_usb_backend_context_flags_check(FuUsbBackend *self) +{ +#if G_USB_CHECK_VERSION(0, 4, 1) + FuContext *ctx = fu_backend_get_context(FU_BACKEND(self)); + if (fu_context_has_flag(ctx, FU_CONTEXT_FLAG_SAVE_EVENTS)) { + g_debug("saving FuUsbBackend events"); + g_usb_context_set_flags(self->usb_ctx, G_USB_CONTEXT_FLAGS_SAVE_EVENTS); + } +#endif +} + +static void +fu_usb_backend_context_flags_notify_cb(FuContext *ctx, GParamSpec *pspec, FuUsbBackend *self) +{ + fu_usb_backend_context_flags_check(self); +} + static gboolean fu_usb_backend_setup(FuBackend *backend, FuProgress *progress, GError **error) { @@ -87,6 +105,11 @@ fu_usb_backend_setup(FuBackend *backend, FuProgress *progress, GError **error) return FALSE; } g_object_weak_ref(G_OBJECT(self->usb_ctx), fu_usb_backend_context_finalized_cb, self); + g_signal_connect(fu_backend_get_context(backend), + "notify::flags", + G_CALLBACK(fu_usb_backend_context_flags_notify_cb), + self); + fu_usb_backend_context_flags_check(self); return TRUE; } @@ -120,9 +143,7 @@ static gboolean fu_usb_backend_coldplug(FuBackend *backend, FuProgress *progress, GError **error) { FuUsbBackend *self = FU_USB_BACKEND(backend); -#if G_USB_CHECK_VERSION(0, 4, 0) - FuContext *ctx = fu_backend_get_context(backend); -#endif + g_autoptr(GPtrArray) usb_devices = NULL; /* progress */ @@ -130,12 +151,6 @@ fu_usb_backend_coldplug(FuBackend *backend, FuProgress *progress, GError **error fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "enumerate"); fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 99, "add-devices"); -#if G_USB_CHECK_VERSION(0, 4, 0) - /* save events */ - if (fu_context_has_flag(ctx, FU_CONTEXT_FLAG_SAVE_EVENTS)) - g_usb_context_set_flags(self->usb_ctx, G_USB_CONTEXT_FLAGS_SAVE_EVENTS); -#endif - /* no insight */ g_usb_context_enumerate(self->usb_ctx); fu_progress_step_done(progress);