mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
GCS USB: Make sure to fully unregister all the callbacks when disconnect.
This commit is contained in:
parent
9b7060a491
commit
1aadcf4e70
@ -69,18 +69,18 @@ static hid_t *last_hid = NULL;
|
|||||||
// Make sure we use the correct runloop
|
// Make sure we use the correct runloop
|
||||||
CFRunLoopRef the_correct_runloop = NULL;
|
CFRunLoopRef the_correct_runloop = NULL;
|
||||||
struct hid_struct {
|
struct hid_struct {
|
||||||
IOHIDDeviceRef ref;
|
IOHIDDeviceRef ref;
|
||||||
int open;
|
int open;
|
||||||
uint8_t buffer[BUFFER_SIZE];
|
uint8_t buffer[BUFFER_SIZE];
|
||||||
buffer_t *first_buffer;
|
buffer_t *first_buffer;
|
||||||
buffer_t *last_buffer;
|
buffer_t *last_buffer;
|
||||||
struct hid_struct *prev;
|
struct hid_struct *prev;
|
||||||
struct hid_struct *next;
|
struct hid_struct *next;
|
||||||
};
|
};
|
||||||
struct buffer_struct {
|
struct buffer_struct {
|
||||||
struct buffer_struct *next;
|
struct buffer_struct *next;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
uint8_t buf[BUFFER_SIZE];
|
uint8_t buf[BUFFER_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void add_hid(hid_t *);
|
static void add_hid(hid_t *);
|
||||||
|
@ -383,29 +383,29 @@ bool RawHID::open(OpenMode mode)
|
|||||||
|
|
||||||
void RawHID::close()
|
void RawHID::close()
|
||||||
{
|
{
|
||||||
emit aboutToClose();
|
emit aboutToClose();
|
||||||
|
|
||||||
m_mutex->lock();
|
m_mutex->lock();
|
||||||
|
|
||||||
if (m_readThread)
|
if (m_readThread)
|
||||||
{
|
{
|
||||||
m_readThread->terminate();
|
m_readThread->terminate();
|
||||||
delete m_readThread; // calls wait
|
delete m_readThread; // calls wait
|
||||||
m_readThread = NULL;
|
m_readThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_writeThread)
|
if (m_writeThread)
|
||||||
{
|
{
|
||||||
m_writeThread->terminate();
|
m_writeThread->terminate();
|
||||||
delete m_writeThread;
|
delete m_writeThread;
|
||||||
m_writeThread = NULL;
|
m_writeThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev.close(m_deviceNo);
|
dev.close(m_deviceNo);
|
||||||
|
|
||||||
m_mutex->unlock();
|
m_mutex->unlock();
|
||||||
|
|
||||||
emit closed();
|
emit closed();
|
||||||
|
|
||||||
QIODevice::close();
|
QIODevice::close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user