From 95175b44e9353a458caf866904f788f0edb711ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 24 Oct 2018 20:57:39 +0200 Subject: [PATCH] Prevent recently closed window from having actions performed on it (#8143) Fixes #8121 --- src/openrct2-ui/windows/Options.cpp | 2 +- src/openrct2-ui/windows/TextInput.cpp | 9 ++++++--- src/openrct2-ui/windows/TileInspector.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 254957c4ec..378e3c3486 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -659,7 +659,7 @@ static void window_options_mouseup(rct_window* w, rct_widgetindex widgetIndex) { case WIDX_CLOSE: window_close(w); - break; + return; case WIDX_TAB_1: case WIDX_TAB_2: case WIDX_TAB_3: diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index 3f833db3e9..9774e0952d 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -285,11 +285,13 @@ void window_text_input_key(rct_window* w, char keychar) { context_stop_text_input(); window_close(w); - rct_window* calling_w = window_find_by_number(calling_class, calling_number); + // Window was closed and its unique_ptr is gone, + // don't try invalidating it. + w = window_find_by_number(calling_class, calling_number); // Pass back the text that has been entered. // ecx when nonzero means text input success - if (calling_w) - window_event_textinput_call(calling_w, calling_widget, text_input); + if (w) + window_event_textinput_call(w, calling_widget, text_input); } window_invalidate(w); @@ -303,6 +305,7 @@ void window_text_input_update7(rct_window* w) if (!calling_w) { window_close(w); + return; } // Used to blink the cursor. diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index ec3a33aa77..a0f3a2d27b 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -796,7 +796,7 @@ static void window_tile_inspector_mouseup(rct_window* w, rct_widgetindex widgetI case WIDX_CLOSE: tool_cancel(); window_close(w); - break; + return; case WIDX_BUTTON_CORRUPT: window_tile_inspector_insert_corrupt_element(windowTileInspectorSelectedIndex); break;