]> git.mxchange.org Git - flightgear.git/commitdiff
- don't crash if user clicked "Apply" but hasn't selected an airport
authormfranz <mfranz>
Sat, 25 Mar 2006 08:47:53 +0000 (08:47 +0000)
committermfranz <mfranz>
Sat, 25 Mar 2006 08:47:53 +0000 (08:47 +0000)
- re-order information from  "LOXT  Tulln"  to  "Tulln  (LOXT)".
  The list is sorted by airport name and columns aren't aligned, so this
  looks way cleaner.

src/GUI/AirportList.cxx

index 16f9785d037664420a3c0199f7459286111c6b5c..5b28e6bf29fc4fbd6213e64f197d0e95079b8e71 100644 (file)
@@ -17,12 +17,12 @@ AirportList::AirportList (int x, int y, int width, int height)
     _content = new char *[_nAirports+1];
     for (int i = 0; i < _nAirports; i++) {
         const FGAirport *airport = _airports->getAirport(i);
-        snprintf(buf, 1023, "%s  %s",
-                 airport->getId().c_str(),
-                 airport->getName().c_str());
+        snprintf(buf, 1023, "%s  (%s)",
+                 airport->getName().c_str(),
+                 airport->getId().c_str());
 
         unsigned int buf_len = (strlen(buf) > 1023) ? 1023 : strlen(buf);
-        
+
         _content[i] = new char[buf_len+1];
         memcpy(_content[i], buf, buf_len);
         _content[i][buf_len] = '\0';
@@ -43,7 +43,11 @@ AirportList::~AirportList ()
 char *
 AirportList::getListStringValue ()
 {
-    return (char *)_airports->getAirport(getListIntegerValue())->getId().c_str();
+    int i = getListIntegerValue();
+    if (i >= 0)
+        return (char *)_airports->getAirport(i)->getId().c_str();
+    else
+        return "";
 }
 
 // end of AirportList.cxx