- char buf[1024];
-
- _airports = globals->get_airports();
- _nAirports = _airports->size();
-
- _content = new char *[_nAirports+1];
- for (int i = 0; i < _nAirports; i++) {
- const FGAirport *airport = _airports->getAirport(i);
- snprintf(buf, 1023, "%s %s",
- airport->_id.c_str(),
- airport->_name.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';
- }
- _content[_nAirports] = 0;
- newList(_content);
+ destroy_list();
+}
+
+
+void
+AirportList::create_list()
+{
+ char **content = FGAirport::searchNamesAndIdents(_filter);
+ int n = (content[0] != NULL) ? 1 : 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;