Skip to content

Commit

Permalink
Sync Homeform loading with bluetooth engine (#1940)
Browse files Browse the repository at this point in the history
* Update python scripts to use AI.Server for OCR #1847

* Update bluetoothdevicetestsuite.cpp

* Update bluetooth.cpp
  • Loading branch information
cagnulein authored Jan 3, 2024
1 parent 9065ef0 commit 3dfe880
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class bluetooth : public QObject, public SignalHandler {
bluetoothdevice *heartRateDevice() { return heartRateBelt; }
QList<QBluetoothDeviceInfo> devices;
bool onlyDiscover = false;
volatile bool homeformLoaded = false;

private:
bool useDiscovery = false;
Expand Down
4 changes: 4 additions & 0 deletions src/homeform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -653,6 +655,8 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) {
});
});
#endif

bluetoothManager->homeformLoaded = true;
}

void homeform::setActivityDescription(QString desc) { activityDescription = desc; }
Expand Down
1 change: 1 addition & 0 deletions tst/Devices/bluetoothdevicetestsuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void BluetoothDeviceTestSuite<T>::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.";
Expand Down

0 comments on commit 3dfe880

Please sign in to comment.