mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Use waitFor instead of timer
See e79bede0aa
. We rather use wait in combination
with spinning the event loop.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
f6768cedf3
commit
6031692a39
2 changed files with 4 additions and 8 deletions
|
@ -60,7 +60,6 @@ void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, con
|
|||
Q_UNUSED(c)
|
||||
|
||||
receivedPackets.append(value);
|
||||
waitForPacket.exit();
|
||||
}
|
||||
|
||||
void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value)
|
||||
|
@ -155,13 +154,11 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
|
|||
if (list.isEmpty())
|
||||
return DC_STATUS_IO;
|
||||
|
||||
QTimer timer;
|
||||
int msec = BLE_TIMEOUT;
|
||||
timer.setSingleShot(true);
|
||||
|
||||
waitForPacket.connect(&timer, SIGNAL(timeout()), SLOT(quit()));
|
||||
timer.start(msec);
|
||||
waitForPacket.exec();
|
||||
while (msec > 0 && receivedPackets.isEmpty()) {
|
||||
waitFor(100);
|
||||
msec -= 100;
|
||||
};
|
||||
}
|
||||
|
||||
// Still no packet?
|
||||
|
|
|
@ -36,7 +36,6 @@ private:
|
|||
|
||||
QLowEnergyController *controller = nullptr;
|
||||
QList<QByteArray> receivedPackets;
|
||||
QEventLoop waitForPacket;
|
||||
bool isCharacteristicWritten;
|
||||
dc_user_device_t *device;
|
||||
|
||||
|
|
Loading…
Reference in a new issue