diydrones/apm_planner — pull request #537 by nbrachet (2014-12-04 00:04:15+00:00)
Title: Comm: EXC_BAD_ACCESS in TCPLink

Comm: Make sure link is disconnect from UAS so we don't try to send messages, heartbeat in particular, through a disconnected link.

Addresses the following EXC_BAD_ACCESS:
```
* thread #1: tid = 0x22d86, 0x000000010213d7da QtCore`QIODevice::write(char const*, long long) + 26, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x000000010213d7da QtCore`QIODevice::write(char const*, long long) + 26
QtCore`QIODevice::write(char const*, long long) + 26:
-> 0x10213d7da: movq 0x8(%rbx), %r13
0x10213d7de: movl 0x70(%r13), %eax
0x10213d7e2: testb $0x2, %al
0x10213d7e4: je 0x10213d8bb ; QIODevice::write(char const*, long long) + 251
(lldb) bt
* thread #1: tid = 0x22d86, 0x000000010213d7da QtCore`QIODevice::write(char const*, long long) + 26, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x000000010213d7da QtCore`QIODevice::write(char const*, long long) + 26
frame #1: 0x0000000100313bd1 apmplanner2`TCPLink::writeBytes(this=0x000000011e1acaa0, data=0x00007fff5fbfc3c0, size=17) + 65 at TCPLink.cc:157
frame #2: 0x000000010025b4f2 apmplanner2`UAS::sendMessage(this=0x00000001081d3a00, link=0x000000011e1acaa0, message=) + 354 at UAS.cc:2018
frame #3: 0x0000000100259e63 apmplanner2`UAS::sendMessage(this=0x00000001081d3a00, message=) + 899 at UAS.cc:1944
frame #4: 0x000000010025b777 apmplanner2`UAS::sendHeartbeat(this=0x00000001081d3a00) + 311 at UAS.cc:1993
```