1
0
Fork 0

Attempting to fix AIAircraft/controller crash

Add an assertion that controller has been cleared before the AIAircraft
destructor is run. If it’s not, then we are too late, don’t try to
sign off since the controller is probably gone.

Sentry-Id: FLIGHTGEAR-15
This commit is contained in:
James Turner 2021-04-25 18:56:55 +01:00
parent 14d01ccffe
commit 6e42b9ae02
2 changed files with 17 additions and 5 deletions

View file

@ -115,9 +115,15 @@ FGAIAircraft::FGAIAircraft(FGAISchedule* ref) : /* HOT must be disabled for AI A
}
FGAIAircraft::~FGAIAircraft() {
if (controller)
controller->signOff(getID());
FGAIAircraft::~FGAIAircraft()
{
assert(!controller);
if (controller) {
// we no longer signOff from controller here, controller should
// have been cleared using clearATCCOntrollers
// see FLIGHTGEAR-15 on Sentry
SG_LOG(SG_AI, SG_ALERT, "Destruction of AIAircraft which was not unbound");
}
}
@ -419,6 +425,10 @@ double FGAIAircraft::calcVerticalSpeed(double vert_ft, double dist_m, double spe
void FGAIAircraft::clearATCController()
{
if (controller) {
controller->signOff(getID());
}
controller = 0;
prevController = 0;
towerController = 0;

View file

@ -561,9 +561,11 @@ FGATCController::FGATCController()
FGATCController::~FGATCController()
{
if (initialized) {
auto mgr = globals->get_subsystem<FGATCManager>();
mgr->removeController(this);
}
}
void FGATCController::init()
{