From 44d1fc42530a304e501e4f41ff0c26bf19971e6a Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 30 Oct 2015 17:23:16 +0000 Subject: (svn r27425) -Fix [FS#5842]: Crash when switching to or taking over companies, when an order window of a vehicle of the new company was opened. Now close those windows. --- src/order_gui.cpp | 6 ++++++ src/window.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/src/order_gui.cpp b/src/order_gui.cpp index d4feae35c..3ca29e087 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1713,6 +1713,12 @@ void ShowOrdersWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_TIMETABLE, v->index, false); if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != NULL) return; + /* Using a different WindowDescs for _local_company causes problems. + * Due to this we have to close order windows in ChangeWindowOwner/DeleteCompanyWindows, + * because we cannot change switch the WindowDescs and keeping the old WindowDesc results + * in crashed due to missing widges. + * TODO Rewrite the order GUI to not use different WindowDescs. + */ if (v->owner != _local_company) { new OrdersWindow(&_other_orders_desc, v); } else { diff --git a/src/window.cpp b/src/window.cpp index 18e8f3588..1fce1f3a8 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1207,6 +1207,7 @@ void ChangeWindowOwner(Owner old_owner, Owner new_owner) case WC_BUY_COMPANY: case WC_COMPANY: case WC_COMPANY_INFRASTRUCTURE: + case WC_VEHICLE_ORDERS: // Changing owner would also require changing WindowDesc, which is not possible; however keeping the old one crashes because of missing widgets etc.. See ShowOrdersWindow(). continue; default: -- cgit v1.2.3-54-g00ecf