From e354b810fa2a4dfd08997e8765a2f9e31da15dd0 Mon Sep 17 00:00:00 2001 From: mfranz Date: Tue, 18 Apr 2006 15:21:19 +0000 Subject: [PATCH] - work around plib bug that crashes fgfs if no airport was found (empty 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/GUI/AirportList.cxx b/src/GUI/AirportList.cxx index 2cdbd58a3..636232fee 100644 --- a/src/GUI/AirportList.cxx +++ b/src/GUI/AirportList.cxx @@ -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