mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Removed unneeded mutex in the enumeration thread.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2911 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
7d679e01f0
commit
ed4aefbb95
@ -275,9 +275,7 @@ QString pjrc_rawhid::getserial(int num) {
|
||||
//
|
||||
void pjrc_rawhid::close(int num)
|
||||
{
|
||||
hid_t *hid = get_hid(num);
|
||||
if (hid && !hid->open)
|
||||
hid_close(hid);
|
||||
hid_close(get_hid(num));
|
||||
}
|
||||
|
||||
// Chuck Robey wrote a real HID report parser
|
||||
@ -358,6 +356,7 @@ void pjrc_rawhid::free_all_hid(void)
|
||||
void pjrc_rawhid::hid_close(hid_t *hid)
|
||||
{
|
||||
if (!hid) return;
|
||||
if (!hid->handle || !hid->open) return;
|
||||
|
||||
usb_release_interface(hid->usb, hid->iface);
|
||||
|
||||
|
@ -341,9 +341,7 @@ QString pjrc_rawhid::getserial(int num)
|
||||
//
|
||||
void pjrc_rawhid::close(int num)
|
||||
{
|
||||
hid_t *hid = get_hid(num);
|
||||
if (hid && hid->open)
|
||||
hid_close(hid);
|
||||
hid_close(get_hid(num));
|
||||
}
|
||||
|
||||
void pjrc_rawhid::add_hid(hid_t *h)
|
||||
@ -388,12 +386,10 @@ void pjrc_rawhid::free_all_hid(void)
|
||||
void pjrc_rawhid::hid_close(hid_t *hid)
|
||||
{
|
||||
if (!hid) return;
|
||||
if (!hid->handle || !hid->open) return;
|
||||
|
||||
if (hid->handle)
|
||||
{
|
||||
CloseHandle(hid->handle);
|
||||
hid->handle = NULL;
|
||||
}
|
||||
CloseHandle(hid->handle);
|
||||
hid->handle = NULL;
|
||||
}
|
||||
|
||||
void pjrc_rawhid::print_win32_err(void)
|
||||
|
@ -49,9 +49,7 @@ RawHIDEnumerationThread::RawHIDEnumerationThread(RawHIDConnection *rawhid) :
|
||||
|
||||
RawHIDEnumerationThread::~RawHIDEnumerationThread()
|
||||
{
|
||||
mutex.lock();
|
||||
m_rawhid = NULL; // safe guard
|
||||
mutex.unlock();
|
||||
m_rawhid = NULL; // safe guard
|
||||
|
||||
m_running = false;
|
||||
|
||||
@ -62,8 +60,6 @@ RawHIDEnumerationThread::~RawHIDEnumerationThread()
|
||||
|
||||
void RawHIDEnumerationThread::onRawHidConnectionDestroyed(QObject *obj) // Pip
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (!m_rawhid || m_rawhid != obj)
|
||||
return;
|
||||
|
||||
@ -78,8 +74,6 @@ void RawHIDEnumerationThread::run()
|
||||
|
||||
while (m_running)
|
||||
{
|
||||
mutex.lock(); // Pip
|
||||
|
||||
// update available devices every second (doesn't need more)
|
||||
if (m_rawhid)
|
||||
{
|
||||
@ -103,8 +97,6 @@ void RawHIDEnumerationThread::run()
|
||||
else
|
||||
counter = 0;
|
||||
|
||||
mutex.unlock(); // Pip
|
||||
|
||||
msleep(10);
|
||||
}
|
||||
}
|
||||
@ -153,13 +145,15 @@ QStringList RawHIDConnection::availableDevices()
|
||||
|
||||
QStringList devices;
|
||||
|
||||
if (enablePolling) {
|
||||
if (enablePolling)
|
||||
{
|
||||
pjrc_rawhid dev;
|
||||
//open all device we can
|
||||
|
||||
// open all device we can
|
||||
int opened = dev.open(USB_MAX_DEVICES, USB_VID, USB_PID, USB_USAGE_PAGE, USB_USAGE);
|
||||
|
||||
//for each devices found, get serial number and close it back
|
||||
for(int i=0; i<opened; i++)
|
||||
// for each devices found, get serial number and close it back
|
||||
for (int i = 0; i < opened; i++)
|
||||
{
|
||||
devices.append(dev.getserial(i));
|
||||
dev.close(i);
|
||||
|
@ -64,9 +64,6 @@ protected slots:
|
||||
protected:
|
||||
RawHIDConnection *m_rawhid;
|
||||
bool m_running;
|
||||
|
||||
private:
|
||||
QMutex mutex;
|
||||
};
|
||||
|
||||
|
||||
@ -95,7 +92,6 @@ public:
|
||||
bool deviceOpened() { return (RawHidHandle != NULL); } // Pip
|
||||
|
||||
signals:
|
||||
// void availableDevChanged(QObject *obj); // Pip
|
||||
void deviceClosed(QObject *obj); // Pip
|
||||
|
||||
protected slots:
|
||||
|
Loading…
x
Reference in New Issue
Block a user