Fix #10811: Crash getting row from non-resizable widget. (#10833)

GetScrolled*FromWidget took line height from the widget's resize_y value,
however not all widgets are resizable, resulting in a division-by-zero.

Allow passing line height explicitly in cases where a widget is not
resizable.
This commit is contained in:
PeterN
2023-05-15 18:57:50 +01:00
committed by GitHub
parent e4fd9d41d3
commit 40f567d464
3 changed files with 8 additions and 6 deletions

View File

@@ -501,7 +501,7 @@ public:
break;
case WID_AP_AIRPORT_LIST: {
int num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
int num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
if (num_clicked == INT_MAX) break;
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);