From fe76c807aa98696a30197f239fe6fb0e31adfab3 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 27 Jun 2018 10:11:50 +0100 Subject: [PATCH] Fix #7707: Opening scenario editor closes game Ensure w is updated after closing the dropdown window. --- src/openrct2-ui/input/MouseInput.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index e80df4c758..d0a2193563 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -1257,6 +1257,8 @@ void input_state_widget_pressed(int32_t x, int32_t y, int32_t state, rct_widgeti { if (w) { + auto wClass = w->classification; + auto wNumber = w->number; int32_t dropdown_index = 0; if (w->classification == WC_DROPDOWN) @@ -1315,9 +1317,11 @@ void input_state_widget_pressed(int32_t x, int32_t y, int32_t state, rct_widgeti } } window_event_dropdown_call(cursor_w, cursor_widgetIndex, dropdown_index); - } dropdown_cleanup: - window_close_by_class(WC_DROPDOWN); + window_close_by_class(WC_DROPDOWN); + // Update w as it will be invalid after closing the dropdown window + w = window_find_by_number(wClass, wNumber); + } } _inputState = INPUT_STATE_NORMAL;