1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

GCS USB: Make sure to fully unregister all the callbacks when disconnect.

This commit is contained in:
James Cotton 2012-09-08 19:31:32 -05:00
parent 9b7060a491
commit 1aadcf4e70
2 changed files with 27 additions and 27 deletions

View File

@ -69,18 +69,18 @@ static hid_t *last_hid = NULL;
// Make sure we use the correct runloop
CFRunLoopRef the_correct_runloop = NULL;
struct hid_struct {
IOHIDDeviceRef ref;
int open;
uint8_t buffer[BUFFER_SIZE];
buffer_t *first_buffer;
buffer_t *last_buffer;
struct hid_struct *prev;
struct hid_struct *next;
IOHIDDeviceRef ref;
int open;
uint8_t buffer[BUFFER_SIZE];
buffer_t *first_buffer;
buffer_t *last_buffer;
struct hid_struct *prev;
struct hid_struct *next;
};
struct buffer_struct {
struct buffer_struct *next;
uint32_t len;
uint8_t buf[BUFFER_SIZE];
struct buffer_struct *next;
uint32_t len;
uint8_t buf[BUFFER_SIZE];
};
static void add_hid(hid_t *);

View File

@ -383,29 +383,29 @@ bool RawHID::open(OpenMode mode)
void RawHID::close()
{
emit aboutToClose();
emit aboutToClose();
m_mutex->lock();
m_mutex->lock();
if (m_readThread)
{
m_readThread->terminate();
delete m_readThread; // calls wait
m_readThread = NULL;
}
if (m_readThread)
{
m_readThread->terminate();
delete m_readThread; // calls wait
m_readThread = NULL;
}
if (m_writeThread)
{
m_writeThread->terminate();
delete m_writeThread;
m_writeThread = NULL;
}
if (m_writeThread)
{
m_writeThread->terminate();
delete m_writeThread;
m_writeThread = NULL;
}
dev.close(m_deviceNo);
dev.close(m_deviceNo);
m_mutex->unlock();
m_mutex->unlock();
emit closed();
emit closed();
QIODevice::close();
}