From d135329860541a90d1829b19dd90132fc4d2306e Mon Sep 17 00:00:00 2001 From: alberth Date: Fri, 30 Oct 2009 20:51:36 +0000 Subject: (svn r17906) -Fix [FS#3286]: Fill the vehicle list before initializing the widgets of the vehicle list window. --- src/vehicle_gui.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 51afdeb92..94f4773dc 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -859,6 +859,23 @@ public: this->vehicle_type = (VehicleType)GB(window_number, 11, 5); + /* Set up sorting. Make the window-specific _sorting variable + * point to the correct global _sorting struct so we are freed + * from having conditionals during window operation */ + switch (this->vehicle_type) { + case VEH_TRAIN: this->sorting = &_sorting.train; break; + case VEH_ROAD: this->sorting = &_sorting.roadveh; break; + case VEH_SHIP: this->sorting = &_sorting.ship; break; + case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break; + default: NOT_REACHED(); + } + + this->vehicles.SetListing(*this->sorting); + this->vehicles.ForceRebuild(); + this->vehicles.NeedResort(); + this->BuildVehicleList(company, GB(window_number, 16, 16), window_type); + this->SortVehicleList(); + this->CreateNestedTree(desc); /* Set up the window widgets */ @@ -877,21 +894,6 @@ public: this->vscroll.SetCapacity(this->GetWidget(VLW_WIDGET_LIST)->current_y / this->resize.step_height); this->GetWidget(VLW_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); - /* Set up sorting. Make the window-specific _sorting variable - * point to the correct global _sorting struct so we are freed - * from having conditionals during window operation */ - switch (this->vehicle_type) { - case VEH_TRAIN: this->sorting = &_sorting.train; break; - case VEH_ROAD: this->sorting = &_sorting.roadveh; break; - case VEH_SHIP: this->sorting = &_sorting.ship; break; - case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break; - default: NOT_REACHED(); - } - - this->vehicles.SetListing(*this->sorting); - this->vehicles.ForceRebuild(); - this->vehicles.NeedResort(); - if (this->vehicle_type == VEH_TRAIN) ResizeWindow(this, 65, 0); } -- cgit v1.2.3-54-g00ecf