summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp9
-rw-r--r--src/bluetooth/qbluetoothdevicewatcher_winrt.cpp18
-rw-r--r--src/bluetooth/qbluetoothdevicewatcher_winrt_p.h1
3 files changed, 13 insertions, 15 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index ada8b705..3a4552a4 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -153,19 +153,22 @@ public:
AdvertisementWatcherWrapper() {}
~AdvertisementWatcherWrapper()
{
- unsubscribeFromEvents();
stop();
}
void init()
{
m_watcher.ScanningMode(BluetoothLEScanningMode::Active);
+ }
+ void start() {
subscribeToEvents();
+ m_watcher.Start();
}
- void start() { m_watcher.Start(); }
void stop()
{
- if (canStop())
+ if (canStop()) {
+ unsubscribeFromEvents();
m_watcher.Stop();
+ }
}
signals:
diff --git a/src/bluetooth/qbluetoothdevicewatcher_winrt.cpp b/src/bluetooth/qbluetoothdevicewatcher_winrt.cpp
index 336e3cdc..455e6fc4 100644
--- a/src/bluetooth/qbluetoothdevicewatcher_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicewatcher_winrt.cpp
@@ -64,11 +64,7 @@ QBluetoothDeviceWatcherWinRT::QBluetoothDeviceWatcherWinRT(int id, winrt::hstrin
QBluetoothDeviceWatcherWinRT::~QBluetoothDeviceWatcherWinRT()
{
- if (m_watcher && m_initialized) {
- stop();
- unsubscribeFromEvents();
- m_initialized = false;
- }
+ stop();
}
bool QBluetoothDeviceWatcherWinRT::init()
@@ -78,23 +74,23 @@ bool QBluetoothDeviceWatcherWinRT::init()
"Detection of Bluetooth devices might not work correctly.");
return false;
}
- if (!m_initialized) {
- subscribeToEvents();
- m_initialized = true;
- }
return true;
}
void QBluetoothDeviceWatcherWinRT::start()
{
- if (m_watcher)
+ if (m_watcher) {
+ subscribeToEvents();
m_watcher.Start();
+ }
}
void QBluetoothDeviceWatcherWinRT::stop()
{
- if (m_watcher && canStop())
+ if (m_watcher && canStop()) {
+ unsubscribeFromEvents();
m_watcher.Stop();
+ }
}
void QBluetoothDeviceWatcherWinRT::subscribeToEvents()
diff --git a/src/bluetooth/qbluetoothdevicewatcher_winrt_p.h b/src/bluetooth/qbluetoothdevicewatcher_winrt_p.h
index 603227d7..7435eeb7 100644
--- a/src/bluetooth/qbluetoothdevicewatcher_winrt_p.h
+++ b/src/bluetooth/qbluetoothdevicewatcher_winrt_p.h
@@ -91,7 +91,6 @@ private:
const int m_id; // used to uniquely identify the wrapper
winrt::Windows::Devices::Enumeration::DeviceWatcher m_watcher = nullptr;
- bool m_initialized = false;
winrt::event_token m_addedToken;
winrt::event_token m_removedToken;