]> git.mxchange.org Git - flightgear.git/commitdiff
Avoid crash in ATIS/ATC modules.
authorThorstenB <brehmt@gmail.com>
Sat, 12 Nov 2011 19:51:03 +0000 (20:51 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 12 Nov 2011 19:51:03 +0000 (20:51 +0100)
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.

src/ATCDCL/ATCDialogOld.cxx
src/ATCDCL/atis.cxx

index bb3cc1650fa46eefd11cb9f854e43d2fa61a72e1..20e2f1f8371f3797c31be1f803e66311433dcc62 100644 (file)
@@ -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;
index dad36fb0a8c351aa2a1584e5847d2e44ba403659..b87369e1a01b7c41c6a91c96cc9a89d801e34ff0 100644 (file)
@@ -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");