[gnome-bluetooth] lib: Don't enable/disable discovery again if already enabled
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] lib: Don't enable/disable discovery again if already enabled
- Date: Wed, 23 Feb 2022 13:01:11 +0000 (UTC)
commit 65becb0c2a019a683af3f3a2fefa9391e2cfdcef
Author: Jonas Dreßler <verdre v0yd nl>
Date: Fri Feb 18 11:14:58 2022 +0100
lib: Don't enable/disable discovery again if already enabled
We have a private property to keep track of this already, let's use it
and bail out of _bluetooth_client_set_default_adapter_discovering() if
we're already discovering.
lib/bluetooth-client.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 54ecc40d..4705cdb5 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1084,6 +1084,9 @@ _bluetooth_client_set_default_adapter_discovering (BluetoothClient *client,
g_autoptr(GDBusProxy) adapter = NULL;
GVariantBuilder builder;
+ if (client->discovery_started == discovering)
+ return;
+
adapter = _bluetooth_client_get_default_adapter (client);
if (adapter == NULL) {
g_debug ("%s discovery requested, but no default adapter",
@@ -1091,6 +1094,8 @@ _bluetooth_client_set_default_adapter_discovering (BluetoothClient *client,
return;
}
+ client->discovery_started = discovering;
+
if (discovering) {
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add (&builder, "{sv}",
@@ -1102,7 +1107,6 @@ _bluetooth_client_set_default_adapter_discovering (BluetoothClient *client,
client);
}
- client->discovery_started = discovering;
if (discovering) {
g_debug ("Starting discovery on %s", g_dbus_proxy_get_object_path (adapter));
adapter1_call_start_discovery (ADAPTER1 (adapter),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]