summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-18 17:04:44 +0000
committerDarkvater <darkvater@openttd.org>2006-11-18 17:04:44 +0000
commit53f954edd3ecf5f9199ee684ac39685a481f8e97 (patch)
tree8c4132a7ae7df56d2180aa2fa9fa2d88c5cbcf76
parentb3c48c0a84323838b5104e422d11b8a1250325c8 (diff)
downloadopenttd-53f954edd3ecf5f9199ee684ac39685a481f8e97.tar.xz
(svn r7206) -Codechange: Remove (some of) the magic needed for windows that could be invalid after
a call to DeleteWindow() somewhere else. Also do some cleanup with AllowWindowDescFront()
-rw-r--r--depot_gui.c5
-rw-r--r--engine_gui.c11
-rw-r--r--misc_gui.c2
-rw-r--r--network_gui.c5
-rw-r--r--roadveh_gui.c3
-rw-r--r--ship_gui.c3
-rw-r--r--vehicle_gui.c1
-rw-r--r--widget.c5
8 files changed, 6 insertions, 29 deletions
diff --git a/depot_gui.c b/depot_gui.c
index e7b7fbb1c..da879bb42 100644
--- a/depot_gui.c
+++ b/depot_gui.c
@@ -189,11 +189,8 @@ static void DepotSellAllWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch (e->we.click.widget) {
case 4:
- /* Weird issue here. If We execute the DoCommandP first, then the window is not closed */
- DeleteWindow(w);
DoCommandP(tile, vehicle_type, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES);
- break;
-
+ /* Fallthrough */
case 3:
DeleteWindow(w);
break;
diff --git a/engine_gui.c b/engine_gui.c
index 30a5e2cce..30c294b1e 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -93,12 +93,10 @@ static void EnginePreviewWndProc(Window *w, WindowEvent *e)
case WE_CLICK:
switch (e->we.click.widget) {
- case 3:
- DeleteWindow(w);
- break;
-
case 4:
DoCommandP(0, w->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW);
+ /* Fallthrough */
+ case 3:
DeleteWindow(w);
break;
}
@@ -117,10 +115,7 @@ static const WindowDesc _engine_preview_desc = {
void ShowEnginePreviewWindow(EngineID engine)
{
- Window *w;
-
- w = AllocateWindowDesc(&_engine_preview_desc);
- w->window_number = engine;
+ Window *w = AllocateWindowDescFront(&_engine_preview_desc, engine);
}
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
diff --git a/misc_gui.c b/misc_gui.c
index beb3e4c4e..0a6b19ccc 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1856,8 +1856,6 @@ void ShowCheatWindow(void)
DeleteWindowById(WC_CHEATS, 0);
w = AllocateWindowDesc(&_cheats_desc);
-
- if (w != NULL) SetWindowDirty(w);
}
/** Resize the widgets in a window
diff --git a/network_gui.c b/network_gui.c
index 2e60fcac5..05ed7379d 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -1258,11 +1258,6 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
if (index >= 0 && e->we.popupmenu.pt.y >= w->top)
HandleClientListPopupClick(index, WP(w,menu_d).main_button);
- // Sometimes, because of the bad DeleteWindow-proc, the 'w' pointer is
- // invalid after the last functions (mostly because it kills a window
- // that is in front of 'w', and because of a silly memmove, the address
- // 'w' was pointing to becomes invalid), so we need to refetch
- // the right address...
DeleteWindowById(WC_TOOLBAR_MENU, 0);
} break;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index fef339163..e2c3ccf9d 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -534,8 +534,7 @@ void ShowBuildRoadVehWindow(TileIndex tile)
DeleteWindowById(WC_BUILD_VEHICLE, tile);
- w = AllocateWindowDesc(&_new_road_veh_desc);
- w->window_number = tile;
+ w = AllocateWindowDescFront(&_new_road_veh_desc, tile);
w->vscroll.cap = 8;
w->widget[2].data = (w->vscroll.cap << 8) + 1;
diff --git a/ship_gui.c b/ship_gui.c
index 0dbe32468..90663533a 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -357,8 +357,7 @@ void ShowBuildShipWindow(TileIndex tile)
DeleteWindowById(WC_BUILD_VEHICLE, tile);
- w = AllocateWindowDesc(&_new_ship_desc);
- w->window_number = tile;
+ w = AllocateWindowDescFront(&_new_ship_desc, tile);
w->vscroll.cap = 4;
w->widget[2].data = (w->vscroll.cap << 8) + 1;
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 6ec40f397..0fef61104 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -454,7 +454,6 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
WP(w, refit_d).order = order;
if (w != NULL) {
- w->window_number = v->index;
w->caption_color = v->owner;
w->vscroll.cap = 8;
w->resize.step_height = 14;
diff --git a/widget.c b/widget.c
index 5b6842227..cd2790af2 100644
--- a/widget.c
+++ b/widget.c
@@ -616,8 +616,6 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e)
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask)
{
- WindowNumber num;
- WindowClass cls;
int i;
const Widget *wi;
Window *w2;
@@ -627,10 +625,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
int screen_top, screen_bottom;
bool scroll = false;
- cls = w->window_class;
- num = w->window_number;
DeleteWindowById(WC_DROPDOWN_MENU, 0);
- w = FindWindowById(cls, num);
if (is_dropdown_menu_shown) return;