Unverified Commit 95ed22c4 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7542 from DonLakeFlyer/ADSB

Fix ADSB vehicle timeout
parents 49e27997 d8512cc2
......@@ -3756,12 +3756,7 @@ void Vehicle::_handleADSBVehicle(const mavlink_message_t& message)
mavlink_msg_adsb_vehicle_decode(&message, &adsbVehicle);
if (adsbVehicle.flags | ADSB_FLAGS_VALID_COORDS) {
if (_adsbICAOMap.contains(adsbVehicle.ICAO_address)) {
if (adsbVehicle.tslc > maxTimeSinceLastSeen) {
ADSBVehicle* vehicle = _adsbICAOMap[adsbVehicle.ICAO_address];
_adsbVehicles.removeOne(vehicle);
_adsbICAOMap.remove(adsbVehicle.ICAO_address);
vehicle->deleteLater();
} else {
if (adsbVehicle.tslc <= maxTimeSinceLastSeen) {
_adsbICAOMap[adsbVehicle.ICAO_address]->update(adsbVehicle);
}
} else if (adsbVehicle.tslc <= maxTimeSinceLastSeen) {
......@@ -3879,15 +3874,13 @@ void Vehicle::_trafficUpdate(bool alert, QString traffic_id, QString vehicle_id,
}
void Vehicle::_adsbTimerTimeout()
{
// TODO: take into account _adsbICAOMap as well? Needs to be tested, especially the timeout
for (auto it = _trafficVehicleMap.begin(); it != _trafficVehicleMap.end();) {
if (it.value()->expired()) {
_adsbVehicles.removeOne(it.value());
delete it.value();
it = _trafficVehicleMap.erase(it);
} else {
++it;
// Remove all expired ADSB vehicle whether from AirMap or ADSB Mavlink
for (int i=_adsbVehicles.count()-1; i>=0; i--) {
ADSBVehicle* adsbVehicle = _adsbVehicles.value<ADSBVehicle*>(i);
if (adsbVehicle->expired()) {
qDebug() << "ADSB expired";
_adsbVehicles.removeAt(i);
adsbVehicle->deleteLater();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment