From 8e7eedf59390ea77026d772f76698946af4a1de5 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 7 Sep 2014 15:07:22 +0000 Subject: [PATCH] (svn r26789) [1.4] -Backport from trunk: - Fix: Incorrect CFLAGS when enabling gprof profiling (r26737, r26735) - Fix: Do not reset the last selected airport or layout, unless it is really necessary [FS#6083] (r26732) - Fix: Use the normal search path to look for xdg-open at Unix [FS#6077] (r26724) - Fix: Properly check for cargo acceptance of houses [FS#5997] (r26723) Conflicts: src/os/unix/unix.cpp --- config.lib | 8 ++++++-- src/airport_gui.cpp | 23 +++++++++++++++++++++-- src/industry_gui.cpp | 4 ++-- src/os/unix/unix.cpp | 4 ++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/config.lib b/config.lib index 8e3d1cc50e..09ad4078a5 100644 --- a/config.lib +++ b/config.lib @@ -1450,7 +1450,11 @@ make_cflags_and_ldflags() { LDFLAGS="$LDFLAGS -noixemul" fi - CFLAGS="-O2 -fomit-frame-pointer $CFLAGS" + if [ "$enable_profiling" = "0" ]; then + # -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible) + CFLAGS="-fomit-frame-pointer $CFLAGS" + fi + CFLAGS="-O2 $CFLAGS" else OBJS_SUBDIR="debug" @@ -1494,7 +1498,7 @@ make_cflags_and_ldflags() { fi if [ "$enable_profiling" != "0" ]; then - CFLAGS="$CFLAGS -p" + CFLAGS="$CFLAGS -pg" LDFLAGS="$LDFLAGS -pg" fi diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 225a95e5b9..8601d7133b 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -237,8 +237,27 @@ public: this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); this->OnInvalidateData(); - this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount()); - this->SelectFirstAvailableAirport(true); + /* Ensure airport class is valid (changing NewGRFs). */ + _selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1)); + const AirportClass *ac = AirportClass::Get(_selected_airport_class); + this->vscroll->SetCount(ac->GetSpecCount()); + + /* Ensure the airport index is valid for this class (changing NewGRFs). */ + _selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1); + + /* Only when no valid airport was selected, we want to select the first airport. */ + bool selectFirstAirport = true; + if (_selected_airport_index != -1) { + const AirportSpec *as = ac->GetSpec(_selected_airport_index); + if (as->IsAvailable()) { + /* Ensure the airport layout is valid. */ + _selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1); + selectFirstAirport = false; + this->UpdateSelectSize(); + } + } + + if (selectFirstAirport) this->SelectFirstAvailableAirport(true); } virtual ~BuildAirportWindow() diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index bf1d8a0efd..8ee75ab4ab 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2020,7 +2020,7 @@ struct CargoesRow { if (!hs->enabled) continue; for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) { - if (cargo_fld->u.cargo.vertical_cargoes[i] == hs->accepts_cargo[j]) { + if (hs->cargo_acceptance[j] > 0 && cargo_fld->u.cargo.vertical_cargoes[i] == hs->accepts_cargo[j]) { cargo_fld->ConnectCargo(cargo_fld->u.cargo.vertical_cargoes[i], false); goto next_cargo; } @@ -2212,7 +2212,7 @@ struct IndustryCargoesWindow : public Window { if (!hs->enabled || !(hs->building_availability & climate_mask)) continue; for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) { - if (cargoes[i] == hs->accepts_cargo[j]) return true; + if (hs->cargo_acceptance[j] > 0 && cargoes[i] == hs->accepts_cargo[j]) return true; } } } diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index cc4d17ca35..f21d300f9c 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -382,11 +382,11 @@ void OSOpenBrowser(const char *url) args[8] = NULL; #else const char *args[3]; - args[0] = "/usr/bin/xdg-open"; + args[0] = "xdg-open"; args[1] = url; args[2] = NULL; #endif - execv(args[0], const_cast(args)); + execvp(args[0], const_cast(args)); DEBUG(misc, 0, "Failed to open url: %s", url); exit(0); }