X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2FAirportList.cxx;h=bcbe06e09c90dea778a4430228f2d208d93f4313;hb=0f7f7fce6bd57bea6c93f5d40c89f1b741edff45;hp=1b62f0aff3ef823f4e9a21ef699189f153d3eeaf;hpb=9fc99b10e207e8af6b3647651fc82a528ed765d2;p=flightgear.git diff --git a/src/GUI/AirportList.cxx b/src/GUI/AirportList.cxx index 1b62f0aff..bcbe06e09 100644 --- a/src/GUI/AirportList.cxx +++ b/src/GUI/AirportList.cxx @@ -1,14 +1,15 @@ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include
#include #include "AirportList.hxx" - AirportList::AirportList(int x, int y, int width, int height) : puaList(x, y, width, height), GUI_ID(FGCLASS_AIRPORTLIST), - _airports(globals->get_airports()), _content(0) { create_list(); @@ -24,28 +25,9 @@ AirportList::~AirportList() void AirportList::create_list() { - const std::ctype &ct = std::use_facet >(std::locale()); - int num_apt = _airports->size(); - char **content = new char *[num_apt + 1]; - - int n = 0; - for (int i = 0; i < num_apt; i++) { - const FGAirport *apt = _airports->getAirport(i); - std::string entry(' ' + apt->getName() + " (" + apt->getId() + ')'); - - if (!_filter.empty()) { - std::string upper(entry.data()); - ct.toupper((char *)upper.data(), (char *)upper.data() + upper.size()); - - if (upper.find(_filter) == std::string::npos) - continue; - } - - content[n] = new char[entry.size() + 1]; - strcpy(content[n], entry.c_str()); - n++; - } - content[n] = 0; + 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);