ble: keep track of Start/StopDiscovery

discovery-stopped may call stop_discovery() if there
is no client listening, resulting in an infinite loop
pull/14/head
Benjamin Tissoires 2018-01-19 16:46:25 +01:00 committed by Peter Hutterer
parent f4e35df67d
commit 380518d0c7
1 changed files with 11 additions and 0 deletions

View File

@ -277,6 +277,7 @@ class BlueZDeviceManager(GObject.Object):
def __init__(self, **kwargs):
GObject.Object.__init__(self, **kwargs)
self.devices = []
self._discovery = False
def connect_to_bluez(self):
"""
@ -314,6 +315,11 @@ class BlueZDeviceManager(GObject.Object):
This emits the discovery-started signal
"""
self.emit("discovery-started")
if self._discovery:
return
self._discovery = True
for obj in self._om.get_objects():
i = obj.get_interface(ORG_BLUEZ_ADAPTER1)
if i is None:
@ -341,6 +347,11 @@ class BlueZDeviceManager(GObject.Object):
This emits the discovery-stopped signal
"""
if not self._discovery:
return
self._discovery = False
for obj in self._om.get_objects():
i = obj.get_interface(ORG_BLUEZ_ADAPTER1)
if i is None: