(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
structs inside their array, and possibly invalidating pointers higher up. Meaning that any function called within an wndproc could cause unknown/invalid pointers once control was returned to this function. Solved by the introduction of an extra abstraction layer, an array of z-window positions that is only concerned with the pointers.
This commit is contained in:
@@ -102,32 +102,40 @@ static const StringID _rail_types_list[] = {
|
||||
|
||||
void RebuildVehicleLists(void)
|
||||
{
|
||||
Window *w;
|
||||
Window* const *wz;
|
||||
|
||||
FOR_ALL_WINDOWS(wz) {
|
||||
Window *w = *wz;
|
||||
|
||||
for (w = _windows; w != _last_window; ++w)
|
||||
switch (w->window_class) {
|
||||
case WC_TRAINS_LIST: case WC_ROADVEH_LIST:
|
||||
case WC_SHIPS_LIST: case WC_AIRCRAFT_LIST:
|
||||
WP(w, vehiclelist_d).l.flags |= VL_REBUILD;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
default: break;
|
||||
case WC_TRAINS_LIST:
|
||||
case WC_ROADVEH_LIST:
|
||||
case WC_SHIPS_LIST:
|
||||
case WC_AIRCRAFT_LIST:
|
||||
WP(w, vehiclelist_d).l.flags |= VL_REBUILD;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ResortVehicleLists(void)
|
||||
{
|
||||
Window *w;
|
||||
Window* const *wz;
|
||||
|
||||
FOR_ALL_WINDOWS(wz) {
|
||||
Window *w = *wz;
|
||||
|
||||
for (w = _windows; w != _last_window; ++w)
|
||||
switch (w->window_class) {
|
||||
case WC_TRAINS_LIST: case WC_ROADVEH_LIST:
|
||||
case WC_SHIPS_LIST: case WC_AIRCRAFT_LIST:
|
||||
WP(w, vehiclelist_d).l.flags |= VL_RESORT;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
default: break;
|
||||
case WC_TRAINS_LIST:
|
||||
case WC_ROADVEH_LIST:
|
||||
case WC_SHIPS_LIST:
|
||||
case WC_AIRCRAFT_LIST:
|
||||
WP(w, vehiclelist_d).l.flags |= VL_RESORT;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BuildVehicleList(vehiclelist_d* vl, PlayerID owner, StationID station, OrderID order, uint16 depot_airport_index, uint16 window_type)
|
||||
|
||||
Reference in New Issue
Block a user