1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-958: adding patch for map to use proper lock mechanism.

This commit is contained in:
Mathieu Rondonneau 2013-05-25 08:06:41 -07:00
parent 13beee32af
commit 45e18127a3
2 changed files with 6 additions and 9 deletions

View File

@ -32,6 +32,7 @@
#include <QThread>
#include <QMutex>
#include <QSemaphore>
// Arch dependent
#if defined(Q_OS_MAC)
@ -202,7 +203,7 @@ private:
#ifdef __APPLE__
protected:
bool m_terminate;
QSemaphore m_terminate;
void run();
#endif // __APPLE__

View File

@ -42,24 +42,20 @@ static bool HID_GetStrProperty(IOHIDDeviceRef dev, CFStringRef property, QString
/**
Initialize the USB monitor here
*/
USBMonitor::USBMonitor(QObject *parent) : QThread(parent)
USBMonitor::USBMonitor(QObject *parent) : QThread(parent), m_terminate(1)
{
m_instance = this;
hid_manager = NULL;
listMutex = new QMutex();
knowndevices.clear();
qRegisterMetaType<USBPortInfo>("USBPortInfo");
m_terminate = false;
start();
}
USBMonitor::~USBMonitor()
{
m_terminate = true;
while (hid_manager != 0) {
this->sleep(10);
}
m_terminate.tryAcquire();
wait();
}
void USBMonitor::deviceEventReceived()
@ -205,7 +201,7 @@ void USBMonitor::run()
return;
}
while (!m_terminate) {
while (m_terminate.available()) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, false);
}
IOHIDManagerUnscheduleFromRunLoop(hid_manager, loop, kCFRunLoopDefaultMode);