ATC: fix crashes on shutdown
This commit is contained in:
parent
411953e89b
commit
691abf25c5
3 changed files with 25 additions and 6 deletions
|
@ -80,6 +80,7 @@ FGGroundController::FGGroundController() :
|
|||
|
||||
FGGroundController::~FGGroundController()
|
||||
{
|
||||
_isDestroying = true;
|
||||
}
|
||||
|
||||
void FGGroundController::init(FGAirportDynamics* aDynamics)
|
||||
|
@ -153,6 +154,9 @@ Search for and erase an aircraft with a certain id from the activeTraffic vector
|
|||
*/
|
||||
void FGGroundController::signOff(int id)
|
||||
{
|
||||
if (_isDestroying)
|
||||
return;
|
||||
|
||||
// Search the activeTraffic vector to find a traffic vector with our id
|
||||
TrafficVectorIterator i = searchActiveTraffic(id);
|
||||
|
||||
|
|
|
@ -916,10 +916,7 @@ FGTowerController::FGTowerController(FGAirportDynamics *par) :
|
|||
|
||||
FGTowerController::~FGTowerController()
|
||||
{
|
||||
// to avoid the exception described in:
|
||||
// https://sourceforge.net/p/flightgear/codetickets/1864/
|
||||
// we want to ensure AI aircraft signing-off is a no-op now
|
||||
|
||||
_isDestroying = true;
|
||||
clearTrafficControllers(activeTraffic);
|
||||
}
|
||||
|
||||
|
@ -1057,6 +1054,10 @@ void FGTowerController::updateAircraftInformation(int id, double lat, double lon
|
|||
|
||||
void FGTowerController::signOff(int id)
|
||||
{
|
||||
// ensure we don't modify activeTraffic during destruction
|
||||
if (_isDestroying)
|
||||
return;
|
||||
|
||||
// Search activeTraffic for a record matching our id
|
||||
TrafficVectorIterator i = searchActiveTraffic(activeTraffic, id);
|
||||
if (i == activeTraffic.end() || (activeTraffic.empty())) {
|
||||
|
@ -1147,6 +1148,7 @@ FGStartupController::FGStartupController(FGAirportDynamics *par):
|
|||
|
||||
FGStartupController::~FGStartupController()
|
||||
{
|
||||
_isDestroying = true;
|
||||
clearTrafficControllers(activeTraffic);
|
||||
}
|
||||
|
||||
|
@ -1219,6 +1221,10 @@ FGATCInstruction FGStartupController::getInstruction(int id)
|
|||
|
||||
void FGStartupController::signOff(int id)
|
||||
{
|
||||
// ensure we don't modify activeTraffic during destruction
|
||||
if (_isDestroying)
|
||||
return;
|
||||
|
||||
// Search activeTraffic for a record matching our id
|
||||
TrafficVectorIterator i = searchActiveTraffic(activeTraffic, id);
|
||||
|
||||
|
@ -1574,6 +1580,7 @@ FGApproachController::FGApproachController(FGAirportDynamics *par):
|
|||
|
||||
FGApproachController::~FGApproachController()
|
||||
{
|
||||
_isDestroying = true;
|
||||
clearTrafficControllers(activeTraffic);
|
||||
}
|
||||
|
||||
|
@ -1653,7 +1660,11 @@ void FGApproachController::updateAircraftInformation(int id, double lat, double
|
|||
/* Search for and erase traffic record with a specific id */
|
||||
void FGApproachController::signOff(int id)
|
||||
{
|
||||
// Search activeTraffic for a record matching our id
|
||||
// ensure we don't modify activeTraffic during destruction
|
||||
if (_isDestroying)
|
||||
return;
|
||||
|
||||
// Search activeTraffic for a record matching our id
|
||||
TrafficVectorIterator i = searchActiveTraffic(activeTraffic, id);
|
||||
|
||||
if (i == activeTraffic.end() || activeTraffic.empty()) {
|
||||
|
|
|
@ -448,6 +448,10 @@ public:
|
|||
virtual void update(double) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
// guard variable to avoid modifying state during destruction
|
||||
bool _isDestroying = false;
|
||||
|
||||
private:
|
||||
|
||||
AtcMsgDir lastTransmissionDirection;
|
||||
|
|
Loading…
Reference in a new issue