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:
parent
14d01ccffe
commit
6e42b9ae02
2 changed files with 17 additions and 5 deletions
src
|
@ -115,9 +115,15 @@ FGAIAircraft::FGAIAircraft(FGAISchedule* ref) : /* HOT must be disabled for AI A
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGAIAircraft::~FGAIAircraft() {
|
FGAIAircraft::~FGAIAircraft()
|
||||||
if (controller)
|
{
|
||||||
controller->signOff(getID());
|
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()
|
void FGAIAircraft::clearATCController()
|
||||||
{
|
{
|
||||||
|
if (controller) {
|
||||||
|
controller->signOff(getID());
|
||||||
|
}
|
||||||
|
|
||||||
controller = 0;
|
controller = 0;
|
||||||
prevController = 0;
|
prevController = 0;
|
||||||
towerController = 0;
|
towerController = 0;
|
||||||
|
|
|
@ -561,8 +561,10 @@ FGATCController::FGATCController()
|
||||||
|
|
||||||
FGATCController::~FGATCController()
|
FGATCController::~FGATCController()
|
||||||
{
|
{
|
||||||
auto mgr = globals->get_subsystem<FGATCManager>();
|
if (initialized) {
|
||||||
mgr->removeController(this);
|
auto mgr = globals->get_subsystem<FGATCManager>();
|
||||||
|
mgr->removeController(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGATCController::init()
|
void FGATCController::init()
|
||||||
|
|
Loading…
Add table
Reference in a new issue