From: ThorstenB Date: Sat, 12 Nov 2011 19:51:03 +0000 (+0100) Subject: Avoid crash in ATIS/ATC modules. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=12b6e8952a1de7415c35ec66e348774d3d29e071;p=flightgear.git Avoid crash in ATIS/ATC modules. The old ATC_mgr is no longer available/initialized, which caused ATIS/ATC modules to crash when selecting ATIS frequencies. This adds a guard to avoid the crash, but doesn't revive the ATIS feature. --- diff --git a/src/ATCDCL/ATCDialogOld.cxx b/src/ATCDCL/ATCDialogOld.cxx index bb3cc1650..20e2f1f83 100644 --- a/src/ATCDCL/ATCDialogOld.cxx +++ b/src/ATCDCL/ATCDialogOld.cxx @@ -205,7 +205,13 @@ void FGATCDialog::PopupDialog() { button_group->removeChildren("button", false); string label; - FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer(); // Hardwired to comm1 at the moment + FGATCMgr* pAtcMgr = globals->get_ATC_mgr(); + if (!pAtcMgr) + { + SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops..."); + return; + } + FGATC* atcptr = pAtcMgr->GetComm1ATCPointer(); // Hardwired to comm1 at the moment if (!atcptr) { label = "Not currently tuned to any ATC service"; @@ -260,7 +266,13 @@ void FGATCDialog::PopupDialog() { } void FGATCDialog::PopupCallback(int num) { - FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer(); // FIXME - Hardwired to comm1 at the moment + FGATCMgr* pAtcMgr = globals->get_ATC_mgr(); + if (!pAtcMgr) + { + SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops..."); + return; + } + FGATC* atcptr = pAtcMgr->GetComm1ATCPointer(); // FIXME - Hardwired to comm1 at the moment if (!atcptr) return; diff --git a/src/ATCDCL/atis.cxx b/src/ATCDCL/atis.cxx index dad36fb0a..b87369e1a 100644 --- a/src/ATCDCL/atis.cxx +++ b/src/ATCDCL/atis.cxx @@ -76,7 +76,14 @@ FGATIS::FGATIS() : _prev_display(0), refname("atis") { - _vPtr = globals->get_ATC_mgr()->GetVoicePointer(ATIS); + FGATCMgr* pAtcMgr = globals->get_ATC_mgr(); + if (!pAtcMgr) + { + SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops..."); + _vPtr = NULL; + } + else + _vPtr = pAtcMgr->GetVoicePointer(ATIS); _voiceOK = (_vPtr == NULL ? false : true); if (!(_type != ATIS || _type == AWOS)) { SG_LOG(SG_ATC, SG_ALERT, "ERROR - _type not ATIS or AWOS in atis.cxx");