mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-24 13:32:46 +00:00
Partially revert the FuDevice weak reference detection
This causes problems for future patchsets that re-populate the FuDeviceItem.
This commit is contained in:
parent
aa6a56205f
commit
e89ab5976f
@ -95,7 +95,6 @@ G_DEFINE_TYPE (FuEngine, fu_engine, G_TYPE_OBJECT)
|
||||
typedef struct {
|
||||
FuDevice *device;
|
||||
FuPlugin *plugin;
|
||||
FuEngine *self; /* no ref */
|
||||
} FuDeviceItem;
|
||||
|
||||
static void
|
||||
@ -174,49 +173,10 @@ fu_engine_set_percentage (FuEngine *self, guint percentage)
|
||||
g_signal_emit (self, signals[SIGNAL_PERCENTAGE_CHANGED], 0, percentage);
|
||||
}
|
||||
|
||||
static FuDeviceItem *
|
||||
fu_engine_get_item_by_device (FuEngine *self, FuDevice *device)
|
||||
{
|
||||
for (guint i = 0; i < self->devices->len; i++) {
|
||||
FuDeviceItem *item = g_ptr_array_index (self->devices, i);
|
||||
if (item->device == device)
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
fu_engine_device_finalized_cb (gpointer data, GObject *where_the_object_was)
|
||||
{
|
||||
FuEngine *self = FU_ENGINE (data);
|
||||
FuDevice *device = (FuDevice *) where_the_object_was;
|
||||
FuDeviceItem *item;
|
||||
|
||||
item = fu_engine_get_item_by_device (self, device);
|
||||
if (item == NULL) {
|
||||
g_critical ("device was finalized with no item!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* no longer valid */
|
||||
item->device = NULL;
|
||||
|
||||
/* the best we can do is just log a warning to the journal and remove
|
||||
* the device from the daemon list -- DeviceRemoved is not emitted */
|
||||
g_critical ("device from plugin %s was finalized without being removed!",
|
||||
fu_plugin_get_name (item->plugin));
|
||||
g_ptr_array_remove (self->devices, item);
|
||||
fu_engine_emit_changed (self);
|
||||
}
|
||||
|
||||
static void
|
||||
fu_engine_item_free (FuDeviceItem *item)
|
||||
{
|
||||
if (item->device != NULL) {
|
||||
g_object_weak_unref (G_OBJECT (item->device),
|
||||
fu_engine_device_finalized_cb, item->self);
|
||||
g_object_unref (item->device);
|
||||
}
|
||||
g_object_unref (item->device);
|
||||
g_object_unref (item->plugin);
|
||||
g_free (item);
|
||||
}
|
||||
@ -1374,14 +1334,10 @@ fu_engine_add_item (FuEngine *self, FuDevice *device, FuPlugin *plugin)
|
||||
|
||||
/* add helper */
|
||||
item = g_new0 (FuDeviceItem, 1);
|
||||
item->self = self; /* no ref */
|
||||
item->device = g_object_ref (device);
|
||||
item->plugin = g_object_ref (plugin);
|
||||
g_ptr_array_add (self->devices, item);
|
||||
|
||||
/* make some noise if the item is unreffed from under our feet */
|
||||
g_object_weak_ref (G_OBJECT (item->device),
|
||||
fu_engine_device_finalized_cb, self);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user