linux: Fix warning when a duplicate device appears

When a kernel device appears after the Bluetooth device, we could be
trying to bind the model property onto itself on the Bluetooth device.
Avoid this possibility by always binding the property from the bluez
device to the non-bluez device.

GLib-GObject-WARNING **: 20:20:50.644: Unable to bind the same property on the same instance

Fixes: 778b93a336 ("linux: Hide duplicate Logitech Bluetooth devices")
This commit is contained in:
Bastien Nocera 2023-02-28 13:00:59 +01:00
parent b7e406d9f9
commit 46257ff36e

View file

@ -155,16 +155,22 @@ update_duplicate_bluez_device (UpBackend *backend,
{
g_autoptr(UpDevice) other_device = NULL;
UpDevice *bluez_device = NULL;
UpDevice *non_bluez_device = NULL;
g_autofree char *name = NULL;
g_autofree char *serial = NULL;
other_device = find_duplicate_device (backend, added_device);
if (!other_device)
return;
bluez_device = UP_IS_DEVICE_BLUEZ (added_device) ?
added_device : other_device;
if (UP_IS_DEVICE_BLUEZ (added_device)) {
bluez_device = added_device;
non_bluez_device = other_device;
} else {
bluez_device = other_device;
non_bluez_device = added_device;
}
g_object_bind_property (bluez_device, "model",
other_device, "model",
non_bluez_device, "model",
G_BINDING_SYNC_CREATE);
g_object_get (G_OBJECT (bluez_device), "serial", &serial, NULL);
up_device_unregister (bluez_device);