Link ids were being used interchangeably with the mavlink channel for
the link. Link ids handed out as a numerically increasing integer. Once
the counter went past MAVLINK_COMM_NUM_BUFFERS all hell would break
loose and cause memory corruption.
I understand the intent when this was first created but nobody is using it and it no longer fits the context. If and when a need to abstract the serial link comes back, we can revisit this.
I noticed that some times, the disconnect signal would get to the updateConnect button (tool bar) before the link was physically disconnected. That would cause it to count it as a still connected link and get the connect button logic out of sync.
While at it, added an interface to the UDP link to return its configuration instance. That allows the LinkManager to unlink it when disconnecting it.
The goal of this first installment is to organize the code a bit so it's more readable,
clean up a bit of left over cruft, and manage link configurations (and links in general).
There's also a partial fix for the databits and stopbits. I'm unsure how to deal with the logic
around the 'is_cdc' variable, as I can't really follow what it's for.
Plus a large number of other changes to allow for orderly shutdown of
objects without crashes or asserts. This is need for unit tests to
create/delete global state around every test.
This function is called automatically when a QSettings object is destroyed,
so is rarely needed to be called explicitly.
There are still some cases where
a QSettings object is passed-by-reference, so there I left the sync() calls as
it's unclear how permanent those objects are and if they'd call sync() before
application shutdown
Largest change is that once a link is added to LinkManager it maintains
ownership and is responsible for delete. If you need to delete a link
use LinkManager::delete. Also added guard code to assert if a Link is
deleted outside of LinkManager.