mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 04:57:59 +00:00
trivial: Emit a critical warning if something finalizes the GUsbContext
This commit is contained in:
parent
058cfc6775
commit
e0d59d82d5
@ -43,6 +43,12 @@ fu_usb_backend_device_removed_cb(GUsbContext *ctx, GUsbDevice *usb_device, FuBac
|
||||
fu_backend_device_removed(backend, device_tmp);
|
||||
}
|
||||
|
||||
static void
|
||||
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 gboolean
|
||||
fu_usb_backend_setup(FuBackend *backend, GError **error)
|
||||
{
|
||||
@ -53,6 +59,7 @@ fu_usb_backend_setup(FuBackend *backend, GError **error)
|
||||
g_prefix_error(error, "failed to get USB context: ");
|
||||
return FALSE;
|
||||
}
|
||||
g_object_weak_ref(G_OBJECT(self->usb_ctx), fu_usb_backend_context_finalized_cb, self);
|
||||
g_signal_connect(self->usb_ctx,
|
||||
"device-added",
|
||||
G_CALLBACK(fu_usb_backend_device_added_cb),
|
||||
@ -77,8 +84,13 @@ static void
|
||||
fu_usb_backend_finalize(GObject *object)
|
||||
{
|
||||
FuUsbBackend *self = FU_USB_BACKEND(object);
|
||||
if (self->usb_ctx != NULL)
|
||||
|
||||
if (self->usb_ctx != NULL) {
|
||||
g_object_weak_unref(G_OBJECT(self->usb_ctx),
|
||||
fu_usb_backend_context_finalized_cb,
|
||||
self);
|
||||
g_object_unref(self->usb_ctx);
|
||||
}
|
||||
G_OBJECT_CLASS(fu_usb_backend_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user