diff options
author | Lubomir I. Ivanov (VMware) <neolit123@gmail.com> | 2018-05-21 17:16:18 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-29 07:57:50 +0000 |
commit | 515c20f5f20dfb4e665e635a30485d7931ff12df (patch) | |
tree | 69d493821900db9e18055daa0302d7e5a403cdab /src/bluetooth/qbluetoothdevicediscoveryagent_p.h | |
parent | 4ca1d6a02cbcc5347205b231108b6bc2b351a4c7 (diff) |
win32: remove usage of QFuture in qbluetoothdevicediscoveryagent
Introduce a couple of QThread instances and workers for
the Bluetooth Classic and BLE device discovery.
Replaces the usage of QFuture for this file.
Remove includes of QtConcurrent.
This introduced some errors which are solved by including:
- QLoggingCategory in qbluetoothdevicediscoveryagent_win.cpp
- QDataStream and QCoreApplication in qlowenergycontroller_win.cpp
Change-Id: Iba2cbc147c714ae87515294d50cb4e502edd00a7
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_p.h')
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_p.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h index ee3531cb..489ed807 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h @@ -80,7 +80,28 @@ QT_END_NAMESPACE #endif #ifdef QT_WIN_BLUETOOTH -#include <QtConcurrent> +QT_BEGIN_NAMESPACE +class QThread; + +class ThreadWorkerLE : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void discover(); +signals: + void discoveryCompleted(const QVariant res); +}; + +class ThreadWorkerClassic : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void discover(QVariant hSearch); +signals: + void discoveryCompleted(const QVariant res); +}; +QT_END_NAMESPACE + #elif defined(QT_WINRT_BLUETOOTH) #include <QtCore/QPointer> #include <QtCore/QTimer> @@ -177,9 +198,9 @@ private: void finishDiscovery(QBluetoothDeviceDiscoveryAgent::Error errorCode, const QString &errorText); void startLeDevicesDiscovery(); - void completeLeDevicesDiscovery(); + void completeLeDevicesDiscovery(const QVariant res); void startClassicDevicesDiscovery(Qt::HANDLE hSearch = nullptr); - void completeClassicDevicesDiscovery(); + void completeClassicDevicesDiscovery(const QVariant res); void processDiscoveredDevice(const QBluetoothDeviceInfo &foundDevice); @@ -188,8 +209,10 @@ private: bool pendingStart; bool active; - QFutureWatcher<QVariant> *classicScanWatcher; - QFutureWatcher<QVariant> *lowenergyScanWatcher; + QThread *threadLE = nullptr; + QThread *threadClassic = nullptr; + ThreadWorkerLE *threadWorkerLE = nullptr; + ThreadWorkerClassic *threadWorkerClassic = nullptr; #endif #ifdef QT_WINRT_BLUETOOTH |