Codechange: Add and use GetScrolledItemFromWidget to get a list item.
This function returns an iterator, either to the selected item or the container's end. This makes handling the result more robust as indices are not used.
This commit is contained in:
@@ -1454,9 +1454,9 @@ public:
|
||||
break;
|
||||
|
||||
case WID_BRAS_NEWST_LIST: {
|
||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST);
|
||||
if (y >= (int)this->station_classes.size()) return;
|
||||
StationClassID station_class_id = this->station_classes[y];
|
||||
auto it = this->vscroll->GetScrolledItemFromWidget(this->station_classes, pt.y, this, WID_BRAS_NEWST_LIST);
|
||||
if (it == this->station_classes.end()) return;
|
||||
StationClassID station_class_id = *it;
|
||||
if (_railstation.station_class != station_class_id) {
|
||||
StationClass *station_class = StationClass::Get(station_class_id);
|
||||
_railstation.station_class = station_class_id;
|
||||
|
Reference in New Issue
Block a user