mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-04 13:10:19 +00:00
libdfu: Do not ref DfuDevice in DfuTarget so the auto-close logic works
We want to auto-close the device when the recount of DfuDevice drops to zero, but when a composite device has more than one ref this is not going to happen.
This commit is contained in:
parent
8d21237c33
commit
4d4e91da23
@ -59,7 +59,7 @@ typedef enum {
|
|||||||
* Private #DfuTarget data
|
* Private #DfuTarget data
|
||||||
**/
|
**/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DfuDevice *device;
|
DfuDevice *device; /* not refcounted */
|
||||||
gboolean done_setup;
|
gboolean done_setup;
|
||||||
guint8 alt_setting;
|
guint8 alt_setting;
|
||||||
guint8 alt_idx;
|
guint8 alt_idx;
|
||||||
@ -128,8 +128,6 @@ dfu_target_finalize (GObject *object)
|
|||||||
g_free (priv->alt_name);
|
g_free (priv->alt_name);
|
||||||
g_ptr_array_unref (priv->sectors);
|
g_ptr_array_unref (priv->sectors);
|
||||||
g_hash_table_unref (priv->sectors_erased);
|
g_hash_table_unref (priv->sectors_erased);
|
||||||
if (priv->device != NULL)
|
|
||||||
g_object_unref (priv->device);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (dfu_target_parent_class)->finalize (object);
|
G_OBJECT_CLASS (dfu_target_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -411,9 +409,14 @@ dfu_target_new (DfuDevice *device, GUsbInterface *iface)
|
|||||||
DfuTarget *target;
|
DfuTarget *target;
|
||||||
target = g_object_new (DFU_TYPE_TARGET, NULL);
|
target = g_object_new (DFU_TYPE_TARGET, NULL);
|
||||||
priv = GET_PRIVATE (target);
|
priv = GET_PRIVATE (target);
|
||||||
priv->device = g_object_ref (device);
|
priv->device = device;
|
||||||
priv->alt_idx = g_usb_interface_get_index (iface);
|
priv->alt_idx = g_usb_interface_get_index (iface);
|
||||||
priv->alt_setting = g_usb_interface_get_alternate (iface);
|
priv->alt_setting = g_usb_interface_get_alternate (iface);
|
||||||
|
|
||||||
|
/* if we try to ref the target and destroy the device */
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (priv->device),
|
||||||
|
(gpointer *) &priv->device);
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user