diff options
author | rubidium <rubidium@openttd.org> | 2009-01-02 20:59:04 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-01-02 20:59:04 +0000 |
commit | b3f2f40db7ffe7ff0b89a77d232b32302a38cd8c (patch) | |
tree | 12aa6dc7cf0075753009d46f0a0d94eee8def600 | |
parent | bde4b6020a001b78052fce910867ce07c8656f76 (diff) | |
download | openttd-b3f2f40db7ffe7ff0b89a77d232b32302a38cd8c.tar.xz |
(svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
-rw-r--r-- | src/station.cpp | 6 | ||||
-rw-r--r-- | src/station_gui.cpp | 8 | ||||
-rw-r--r-- | src/train_cmd.cpp | 8 | ||||
-rw-r--r-- | src/vehicle.cpp | 4 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 8 | ||||
-rw-r--r-- | src/window.cpp | 10 | ||||
-rw-r--r-- | src/window_func.h | 2 |
7 files changed, 34 insertions, 12 deletions
diff --git a/src/station.cpp b/src/station.cpp index 4bb65b0d8..672c3d320 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -33,6 +33,7 @@ #include "order_func.h" #include "news_func.h" #include "aircraft.h" +#include "vehicle_gui.h" #include "table/sprites.h" #include "table/strings.h" @@ -87,6 +88,11 @@ Station::~Station() InvalidateWindowData(WC_STATION_LIST, this->owner, 0); DeleteWindowById(WC_STATION_VIEW, index); + WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner; + DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11)); + DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11)); + DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11)); + DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11)); /* Now delete all orders that go to the station */ RemoveOrderFromAllVehicles(OT_GOTO_STATION, index); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 0c2bb6dfe..471173f13 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -700,10 +700,10 @@ struct StationViewWindow : public Window { WindowNumber wno = (this->window_number << 16) | VLW_STATION_LIST | GetStation(this->window_number)->owner; - DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11)); - DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11)); - DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11)); - DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11)); + DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false); + DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false); + DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11), false); + DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11), false); } virtual void OnPaint() diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index e98461410..cd085c0d2 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1293,6 +1293,10 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p if (IsFrontEngine(src)) { /* the vehicle was previously a loco. need to free the order list and delete vehicle windows etc. */ DeleteWindowById(WC_VEHICLE_VIEW, src->index); + DeleteWindowById(WC_VEHICLE_ORDERS, src->index); + DeleteWindowById(WC_VEHICLE_REFIT, src->index); + DeleteWindowById(WC_VEHICLE_DETAILS, src->index); + DeleteWindowById(WC_VEHICLE_TIMETABLE, src->index); DeleteVehicleOrders(src); RemoveVehicleFromGroup(src); } @@ -1402,6 +1406,10 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, if (flags & DC_EXEC) { if (v == first && IsFrontEngine(first)) { DeleteWindowById(WC_VEHICLE_VIEW, first->index); + DeleteWindowById(WC_VEHICLE_ORDERS, first->index); + DeleteWindowById(WC_VEHICLE_REFIT, first->index); + DeleteWindowById(WC_VEHICLE_DETAILS, first->index); + DeleteWindowById(WC_VEHICLE_TIMETABLE, first->index); } InvalidateWindow(WC_VEHICLE_DEPOT, first->tile); InvalidateWindowClassesData(WC_TRAINS_LIST, 0); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f479cdbc5..f267c635f 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -672,8 +672,10 @@ void Vehicle::PreDestructor() if (this->IsPrimaryVehicle()) { DeleteWindowById(WC_VEHICLE_VIEW, this->index); - DeleteWindowById(WC_VEHICLE_DETAILS, this->index); DeleteWindowById(WC_VEHICLE_ORDERS, this->index); + DeleteWindowById(WC_VEHICLE_REFIT, this->index); + DeleteWindowById(WC_VEHICLE_DETAILS, this->index); + DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index); InvalidateWindow(WC_COMPANY, this->owner); } InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index afa4e31d3..5c0136390 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1817,10 +1817,10 @@ struct VehicleViewWindow : Window { ~VehicleViewWindow() { - DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number); - DeleteWindowById(WC_VEHICLE_REFIT, this->window_number); - DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number); - DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number); + DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number, false); + DeleteWindowById(WC_VEHICLE_REFIT, this->window_number, false); + DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number, false); + DeleteWindowById(WC_VEHICLE_TIMETABLE, this->window_number, false); } virtual void OnPaint() diff --git a/src/window.cpp b/src/window.cpp index f28d4dbdd..8b4d92ba2 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -492,10 +492,16 @@ Window *FindWindowById(WindowClass cls, WindowNumber number) * Delete a window by its class and window number (if it is open). * @param cls Window class * @param number Number of the window within the window class + * @param force force deletion; if false don't delete when stickied */ -void DeleteWindowById(WindowClass cls, WindowNumber number) +void DeleteWindowById(WindowClass cls, WindowNumber number, bool force) { - delete FindWindowById(cls, number); + Window *w = FindWindowById(cls, number); + if (force || w == NULL || + (w->desc_flags & WDF_STICKY_BUTTON) == 0 || + (w->flags4 & WF_STICKY) == 0) { + delete w; + } } /** diff --git a/src/window_func.h b/src/window_func.h index fb6b290e5..2e3767c97 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -35,7 +35,7 @@ void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_in void InvalidateWindow(WindowClass cls, WindowNumber number); void InvalidateWindowClasses(WindowClass cls); -void DeleteWindowById(WindowClass cls, WindowNumber number); +void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true); void DeleteWindowByClass(WindowClass cls); #endif /* WINDOW_FUNC_H */ |