diff --git a/src/bluetooth.cpp b/src/bluetooth.cpp index 748b59080..2e5b3cb74 100644 --- a/src/bluetooth.cpp +++ b/src/bluetooth.cpp @@ -548,6 +548,14 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) { qDebug() << device.deviceUuid(); #endif + // not required for mobile I guess +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + if(!homeformLoaded) { + qDebug() << "homeform not yet loaded"; + return; + } +#endif + if (onlyDiscover) return; diff --git a/src/bluetooth.h b/src/bluetooth.h index 881186f42..2767f142d 100644 --- a/src/bluetooth.h +++ b/src/bluetooth.h @@ -147,6 +147,7 @@ class bluetooth : public QObject, public SignalHandler { bluetoothdevice *heartRateDevice() { return heartRateBelt; } QList devices; bool onlyDiscover = false; + volatile bool homeformLoaded = false; private: bool useDiscovery = false; diff --git a/src/homeform.cpp b/src/homeform.cpp index 634e0897f..d72941e7f 100644 --- a/src/homeform.cpp +++ b/src/homeform.cpp @@ -503,6 +503,8 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) { QObject::connect(stack, SIGNAL(floatingOpen()), this, SLOT(floatingOpen())); QObject::connect(stack, SIGNAL(openFloatingWindowBrowser()), this, SLOT(openFloatingWindowBrowser())); + qDebug() << "homeform constructor events linked"; + #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) QObject::connect(engine, &QQmlApplicationEngine::quit, &QGuiApplication::quit); #endif @@ -653,6 +655,8 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) { }); }); #endif + + bluetoothManager->homeformLoaded = true; } void homeform::setActivityDescription(QString desc) { activityDescription = desc; } diff --git a/tst/Devices/bluetoothdevicetestsuite.cpp b/tst/Devices/bluetoothdevicetestsuite.cpp index 43b9c8e27..615ff3592 100644 --- a/tst/Devices/bluetoothdevicetestsuite.cpp +++ b/tst/Devices/bluetoothdevicetestsuite.cpp @@ -12,6 +12,7 @@ void BluetoothDeviceTestSuite::tryDetectDevice(bluetooth &bt, try { // It is possible to use an EXPECT_NO_THROW here, but this // way is easier to place a breakpoint on the call to bt.deviceDiscovered. + bt.homeformLoaded = true; bt.deviceDiscovered(deviceInfo); } catch (...) { FAIL() << "Failed to perform device detection.";