]> git.mxchange.org Git - flightgear.git/commitdiff
- work around plib bug that crashes fgfs if no airport was found (empty
authormfranz <mfranz>
Tue, 18 Apr 2006 15:21:19 +0000 (15:21 +0000)
committermfranz <mfranz>
Tue, 18 Apr 2006 15:21:19 +0000 (15:21 +0000)
  list) and the arrows are clicked  (patch sent to plib; workaround it to
  be removed once fgfs officially depends on a plib version that includes
  the fix)
- fix (very unlikely) crash in case the widget is redrawn between list
  destruction and setting of the new list.

src/GUI/AirportList.cxx

index 2cdbd58a3e240b5841ebc4effa1ca6e74a6c8a67..636232feeda3eaa662321456877b08578359204a 100644 (file)
@@ -21,11 +21,8 @@ AirportList::~AirportList ()
 void
 AirportList::create_list ()
 {
-    if (_content)
-        destroy_list();
-
     int num_apt = _airports->size();
-    _content = new char *[num_apt + 1];
+    char **content = new char *[num_apt + 1];
 
     int n = 0;
     for (int i = 0; i < num_apt; i++) {
@@ -35,12 +32,18 @@ AirportList::create_list ()
         if (!_filter.empty() && entry.find(_filter) == STD::string::npos)
             continue;
 
-        _content[n] = new char[entry.size() + 1];
-        strcpy(_content[n], entry.c_str());
+        content[n] = new char[entry.size() + 1];
+        strcpy(content[n], entry.c_str());
         n++;
     }
-    _content[n] = 0;
-    newList(_content);
+    content[n] = 0;
+    // work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up
+    newList(n > 0 ? content : 0);
+
+    if (_content)
+        destroy_list();
+
+    _content = content;
 }
 
 void